I want to use selenium for clicking a textbox, but I get the error. It is a datepicker, when I click this textbox, the popup calendar should appear.
I used this code.
driver.find_element_by_xpath("""//*[@id="startDt"]""").click()
I want to use selenium for clicking a textbox, but I get the error. It is a datepicker, when I click this textbox, the popup calendar should appear.
I used this code.
driver.find_element_by_xpath("""//*[@id="startDt"]""").click()
Instead of this :
driver.find_element_by_xpath("""//*[@id="startDt"]""").click()
use this :
driver.find_element_by_id("startDt").click()
As well as check for Iframe, if the element is inside the frame the switch to frame first and then you can interact with the input tag
1)Go to your browser -> Open the application manually
2)Open inspector window(i.e press function key f12 from your keyboard)
3)Go to console tab, type as below and click on enter:
$x("//*[@id='startDt']");
4)If the element is identified and count is 1 in console then your locator is correct but in Selenium you get NoSuchElementException, then there are high chances the element you are trying to locate is inside the Iframe. If so, figure out the Iframe and switch to it, then try to call findElement method, it should work.
5)If the element is not identified in the console, then your element with the xpath you are using doesn't exists/your xpath is wrong.
You can refer [link][1] for more info on evaluating and validating your xpath procedure
[1]: https://yizeng.me/2014/03/23/evaluate-and-validate-xpath-css-selectors-in-chrome-developer-tools/#:~:text=From%20Console%20panel,%22)%20to%20evaluate%20and%20validate.