我正在尝试在以下链接中点击标有“Pickup”的按钮:
我的代码如下,但是什么也没有发生,直到它以错误的形式失败,报错信息为“元素不可交互”。
代码似乎可以定位一个元素,当我打印'button'时,我得到了一个元素对象。
我尝试使用driver.execute_script来执行onclick属性,但这也没有任何作用。
感谢您的帮助。
pickupurl = 'https://firehouse.alohaorderonline.com/StartOrder.aspx?SelectMenuType=Retail&SelectMenu=1000560&SelectSite=1291'
driver = webdriver.Chrome('d:\\chromedriver\\chromedriver.exe')
driver.implicitly_wait(80)
driver.get(pickupurl)
button = driver.find_elements_by_xpath('//*[@id="ctl00_ctl00_PickupButton"]')
button.click()
代码似乎可以定位一个元素,当我打印'button'时,我得到了一个元素对象。
我尝试使用driver.execute_script来执行onclick属性,但这也没有任何作用。
感谢您的帮助。
onClick
所做的事...但我认为主要问题是,你正在使用find_elements_by_xpath
而不是find_element_by_xpath
,删掉"S"即可。 - Moshe Slavin