0

I need your help to find and identify this element:

HTML: <input type="tel" id="pp-DlfVWS-14" autocomplete="off" name="addCreditCardNumber" class="a-input-text a-form-normal">

Where "DlfVWS" change every refresh. I have tried many combinations with no success and errors for example:

driver.find_element_by_xpath("//input[contains(@id, 'pp-']")

Thanks.

testgen
  • 31
  • 2
  • 1
    Why not use the name attribute instead? `driver.find_element_by_xpath("//input[@name='addCreditCardNumber']")` – row May 28 '21 at 13:23
  • Thanks for your answer I received this answer when tried your answer: selenium.common.exceptions.NoSuchElementException: Message: no such element: Unable to locate element: {"method":"xpath","selector":"//input[@name='addCreditCardNumber']"} – testgen May 28 '21 at 13:31
  • Please share more html or url. – Siebe Jongebloed May 28 '21 at 13:47
  • more html:
    – testgen May 28 '21 at 14:03
  • You can test the xpath in your browser console with the $x command. e.g ``$x("//body']")`` or ``$x("//input[@name='addCreditCardNumber']")``to see that your xpath is ok. Is the element located within an iframe? Is the element available from page render or is it dynamically loaded after page load? – row May 28 '21 at 14:38
  • I searched this on the console, `$x("//input[@name='addCreditCardNumber']")` but just appears when inspect element, before that, the result is null. The element is available when I click on add credit card number, then appears the "floating window" in the center of site with the forms to fill, and the first form is which I can't locate with xpath or other method. :( – testgen May 28 '21 at 15:33
  • It is probably an iframe then? You can use ``driver.switch_to.frame(driver.find_element_by_css_selector('#iframeid'))`` See the following post: https://stackoverflow.com/questions/59588160/access-iframe-input-element-with-webdriver-python – row May 28 '21 at 15:39

0 Answers0