Forms 如何使用SELENIUM PYTHON填写amazon支付表单

Forms 如何使用SELENIUM PYTHON填写amazon支付表单,forms,selenium,iframe,amazon,screen-scraping,Forms,Selenium,Iframe,Amazon,Screen Scraping,这是我代码的一部分,在此我确实单击“添加信用卡或借记卡”并切换框架,因为我将继续填写表格,但出现以下错误: selenium.common.exceptions.NoSuchElementException: Message: no such element: Unable to locate element: {"method":"xpath","selector":"//*[@id="pp-QqmNYT-14&q

这是我代码的一部分,在此我确实单击“添加信用卡或借记卡”并切换框架,因为我将继续填写表格,但出现以下错误:

selenium.common.exceptions.NoSuchElementException: Message: no such element: Unable to locate element: {"method":"xpath","selector":"//*[@id="pp-QqmNYT-14"]"}
这是我的部分代码:

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)
这是我要填写的表格:

看看这是否有效:

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

您是否检查过您正在访问的页面中只有一个帧?我找到了第二个iframe,但没有任何内容是iframe empySo。如果您的开关切换到第二个空的帧,该怎么办。因此,您必须重写switch_to语句。您尝试切换到的帧的属性是什么?与name一样,idf第二个(空iframe)位于第一个iframe内部,我尝试切换的第一个iframe是id='pp-KHHq3T-44',但我无法使用,因为我遇到了此错误