【发布时间】:2020-12-08 01:56:19
【问题描述】:
我正在尝试为www.kith.com 编写一个机器人我刚刚完成了卡号,现在我在卡上的名字上。我找到了 xpath,但它说元素不可交互。
代码:
driver = webdriver.Chrome(executable_path=r'C:\webdrivers\Chromedriver.exe')
driver.get('https://kith.com/products/kith-women-x-coca-cola-cropped-camp-collar-ivory-multi')
#size
driver.find_element_by_xpath('//div[@data-value="M"]').click()
#ATC
driver.find_element_by_xpath('//button[@class="btn product-form__add-to-cart"]').click()
time.sleep(6)
#checkout
driver.find_element_by_xpath('//button[@class="btn ajaxcart__checkout"]').click()
time.sleep(3)
#email
driver.find_element_by_xpath('//input[@placeholder="Email"]').send_keys('example@gmail.com')
#first
driver.find_element_by_xpath('//input[@placeholder="First name"]').send_keys('first')
#last
driver.find_element_by_xpath('//input[@placeholder="Last name"]').send_keys('last')
#address
driver.find_element_by_xpath('//input[@placeholder="Address"]').send_keys('address')
#city
driver.find_element_by_xpath('//input[@placeholder="City"]').send_keys('city')
#zip
driver.find_element_by_xpath('//input[@placeholder="ZIP code"]').send_keys('99999')
#phone number
driver.find_element_by_xpath('//input[@placeholder="Phone"]').send_keys('9999999999' + u'\ue007')
time.sleep(5)
#continue to payment
driver.find_element_by_xpath('//button[@type="submit"]').click()
time.sleep(8)
#payment page
driver.switch_to.frame(driver.find_element_by_class_name("card-fields-iframe"))
driver.find_element_by_id("number").send_keys('1234')
driver.find_element_by_id("number").send_keys('1234')
driver.find_element_by_id("number").send_keys('1234')
driver.find_element_by_id("number").send_keys('1234')
driver.find_element_by_xpath('//input[@id="name"]').send_keys("jake d")
最后一行出现错误。
【问题讨论】:
标签: python selenium selenium-webdriver xpath automation