我如何选择信用卡号码字段为一个硒网络驱动程序测试?
https://secure-store.nike.com/us/checkout/html/billing.jsp?_requestid=173323
cc = driver.find_element_by_id("creditCardNumber")
我得到一个无法定位元素错误在这一行,我不知道为什么。
# click next button
driver.find_element_by_id("shippingSubmit").click()
# enter credit card number
cc = driver.find_element_by_id("creditCardNumber")
cc.click()
cc.clear()
cc.send_keys("4411111111111111")
# enter expiration
selectmonth = Select(driver.find_element_by_id("expirationMonth"))
selectmonth.select_by_value("10")
# enter expiration year
selectyear = Select(driver.find_element_by_id("expirationYear"))
selectyear.select_by_value("2012")
支付表单包装在iframe元素中。在定位元素之前切换到它:
wait = WebDriverWait(driver, 10)
driver.switch_to.frame("billingFormFrame")
cc = wait.until(EC.element_to_be_clickable((By.ID, "creditCardNumber"))
cc.click()
# ...