Search code examples
formsselenium-webdriveriframescreen-scraping

How fill the form of payment amazon using SELENIUM PYTHON


This is a one part of my code, here I do click in 'Add a credit or debit card' and switch the frame, for the I will proceed fill the form but have this error:

selenium.common.exceptions.NoSuchElementException: Message: no such element: Unable to locate element: {"method":"xpath","selector":"//*[@id="pp-QqmNYT-14"]"}

This is my part of code:

self.__driver.find_element(By.LINK_TEXT, 'Add a credit or debit card').click()
self.__driver.switch_to.frame(self.__driver.find_element_by_tag_name('iframe'))
self.__driver.find_element(By.XPATH, '//*[@id="pp-QqmNYT-14"]').send_keys("user admin")
self.__driver.find_element(By.NAME, 'addCreditCardNumber').send_keys(self.cc)

This is the form that I want fill: https://www.amazon.sg/gp/prime/pipeline/membersignup


Solution

  • See if this works:

    self.__driver.switch_to.frame(self.__driver.find_element_by_xpath('.//iframe[contains(@name,'ApxSecureIframe')]'))