我在使用Selenium和Python中的Chrome Web驱动程序编码单击操作时遇到问题.我花了一些时间在谷歌上搜索,发现我必须使用另一种硒工艺才能在Google Chrome浏览器中单击,这对我来说没有任何意义(调用webdrive.Chrome时不是吗?) .尽管我找不到其他任何单击方法,无论是联机还是通过硒模块.
这就是我所拥有的,任何帮助都将不胜感激!谢谢!
编辑:所以我在Selenium中找到了ActionChains模块,似乎也无法使它正常工作.更新了我的代码,仍然卡住了. ChromeDriver真的不支持点击吗?
import selenium
from selenium import webdriver
from selenium.common.exceptions import NoSuchElementException
from selenium.webdriver.common.keys import Keys
import time
chromeOps = webdriver.ChromeOptions()
chromeOps._binary_location = "C:\\Applications\\browser\\Chrome.exe"
chromeOps._arguments = ["--enable-internal-flash"]
browser = webdriver.Chrome("C:\\Applications\\browser\\chromedriver.exe", port=4445, chrome_options=chromeOps)
time.sleep(3)
browser.get("http://example.com")
##selenium.selenium("127.0.0.1", 4445,'*Chrome.exe', 'https://example.com').click("//a[contains(@href,'http://example.com/link')]")
webdriver.ActionChains(browser).click(on_element='//a[contains(@href,"http://example.com/link")]')
解决方法:
当如此简单的事情摆在您面前时,我讨厌它.
clickme = browser.find_element_by_xpath('//a[contains(@href,"http://example.com/link")]')
clickme.click()
版权声明:本文内容由互联网用户自发贡献,该文观点与技术仅代表作者本人。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌侵权/违法违规的内容, 请发送邮件至 [email protected] 举报,一经查实,本站将立刻删除。