Home > Mobile >  How to edit a calendar input element in capybara
How to edit a calendar input element in capybara

Time:06-04

I'm currently trying to edit a calendar input element and set a new date. Here is what I'm trying to do.

Element:

<input  placeholder="MM/DD/YYYY" value="03/01/2022">

Xpath:

/html/body/div[2]/div/div/div/div/div[1]/div/input

My code:

find("ant-calendar-input").set(value='01/01/2022')

I'm getting an error that capybara is unable to find this element.

CodePudding user response:

"ant-calendar-input" as a CSS selector would look for an element of type 'ant-calendar-input' whereas the element you show is of type 'input' with a class of 'ant-calendar-input'. A valid CSS selector to match that element would be something like

find('input.ant-calendar-input').set('01/01/2022')

That being said, you claim this is a calendar input, but the input element is just a text input. I assume this means you are using some type of JS widget that is bound to the input element and therefore may have hidden the original input. If that's the case then you'll need to interact with the elements generated by the widget (like a user would have to) rather than directly with the input element

  • Related