zkyk 发表于 2021-4-24 14:50:38

selenium如何点击javascript:void(0)

网易云阅读
(左右翻页)网址:http://yuedu.163.com/book_reader/4e49ffed976e463dbb7bdaa51d82fee9_4
如何用selenium点击javascript:void(0)的超链接,实现翻页
driver.find_element_by_xpath('/html/body/div/div/div/a').click()
以上代码会报错:selenium.common.exceptions.ElementNotInteractableException: Message: element not interactable

nahongyan1997 发表于 2021-6-23 16:22:16

一行代码搞定:
driver.find_element_by_xpath("//*[@id='J_Horizontal']/div/a").click()

要是不行就两行:
btn = driver.find_element_by_xpath("//*[@id='J_Horizontal']/div/a")

driver.execute_script("arguments.click()",btn)
页: [1]
查看完整版本: selenium如何点击javascript:void(0)