selenium 用什么脚本来填写支付收银台,填框

pgvzfuti  于 2022-11-10  发布在  其他
关注(0)|答案(1)|浏览(128)

这是我在网站上找到的<iframe src="https://cashiers.myshopline.com/pci-sdk/iframe.html?name=number" name="number71dd4df3-f17d-4da6-b4a6-b920dad95e69" id="number71dd4df3-f17d-4da6-b4a6-b920dad95e69" style="width: 100%; height: 100%; border: none;"></iframe><input id="input-file" autocomplete="cc-number" inputmode="numeric" style="padding: 20px 0px 0px 16px;font-family:Helvetica Neue,Arial,sans-serif">
enter image description here
https://www.goopi.co/

c9qzyr3d

c9qzyr3d1#

下一次,把你的问题清楚地贴出来。
这些元素位于单独的IFRAME中,试试这个:

WebDriverWait(driver, 10).until(EC.frame_to_be_available_and_switch_to_it((By.XPATH, "//iframe[starts-with(@id,'number')]")))
driver.find_element(By.XPATH, "//input[@id='input-file' and @autocomplete='cc-number']").send_keys("1234 5678 9123 4567")
driver.switch_to.default_content()

WebDriverWait(driver, 10).until(EC.frame_to_be_available_and_switch_to_it((By.XPATH, "//iframe[starts-with(@id,'firstName')]")))
driver.find_element(By.XPATH, "//input[@id='input-file' and @type='text']").send_keys("Test Name")
driver.switch_to.default_content()

WebDriverWait(driver, 10).until(EC.frame_to_be_available_and_switch_to_it((By.XPATH, "//iframe[starts-with(@id,'expDate')]")))
driver.find_element(By.XPATH, "//input[@id='input-file' and @autocomplete='cc-exp']").send_keys("01/23")
driver.switch_to.default_content()

WebDriverWait(driver, 10).until(EC.frame_to_be_available_and_switch_to_it((By.XPATH, "//iframe[starts-with(@id,'cvc')]")))
driver.find_element(By.XPATH, "//input[@id='input-file' and @inputmode='numeric']").send_keys("123")
driver.switch_to.default_content()
time.sleep(2)

terms_chkbox = driver.find_element(By.XPATH, "//input[@type='checkbox' and @name = 'policy']")
driver.execute_script("arguments[0].click();", terms_chkbox)

driver.find_element(By.XPATH, "//button[@id='place-order-recaptcha']").click()

相关问题