0

I ran into an issue with a read-only calendar input box. I need to send a date value to it through Selenium VBA. Here is the snippet of the HTML code I'm looking at:

<input class="dxeEditArea dxeEditAreaSys" id="pickupDate_I" 
name="ctl00$ctl00$MainPane$Content$MainContent$OPUserControl$pickupDate" 
onfocus="ASPx.EGotFocus('pickupDate')" onblur="ASPx.ELostFocus('pickupDate')" 
onchange="ASPx.EValueChanged('pickupDate')" type="text" readonly="">

I put a solution I ended up using as a JS code below as a separate answer.

2 Answers 2

1

Here is the solution I ended up using: run a JavaScript code to replace the value in the field, rather than using SendKeys. This way we bypass readonly attribute that affects .SendKeys, but using .Value inside the script works:

driver.ExecuteScript ("document.getElementById('pickupDate_I').value = '01/01/2010'")
Sign up to request clarification or add additional context in comments.

Comments

0

driver.findElement(By.xpath("//input[@id='pickupDate_I'])).sendKeys("your value");

2 Comments

Thank you, when I enter this line with VBA syntax: driver.FindElementByXPath("//input[@id='pickupDate_I']).SendKeys "01/09/2021" I get an error that highlights "01" and the error msg says: Compile error: Expected: list separator or ) . Not sure what the problem might be here.
I got this error message resolved with updated syntax, however this line doesn't do anything: driver.FindElementByXPath("//input[@id='pickupDate_I']").SendKeys "01/09/2021" I suspect this is because the initial HTML has a read-only tag at the end. What would we a way to bypass it?

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.