Dus*_*tin 3 python selenium google-chrome webdriver
我在 Python 中使用 Selenium 和 Chrome Web 驱动程序编写单击操作时遇到问题。我花了一些时间在谷歌上搜索,发现我必须使用另一个 selenium 进程才能在 Google Chrome 中进行点击,这对我来说没有意义(在调用 webdrive.Chrome 时会不会是这样?) . 虽然我找不到任何其他方法来点击,无论是在线还是通过 seleniums 模块。
这是我所拥有的,任何帮助表示赞赏!谢谢!
编辑:所以我在 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")]')
Run Code Online (Sandbox Code Playgroud)
当如此简单的事情就在你面前时,我讨厌它。
clickme = browser.find_element_by_xpath('//a[contains(@href,"http://example.com/link")]')
clickme.click()
Run Code Online (Sandbox Code Playgroud)
| 归档时间: |
|
| 查看次数: |
11267 次 |
| 最近记录: |