【问题标题】:Python/Selenium - Chrome Web Driver, Click ActionPython/Selenium - Chrome Web 驱动程序,点击操作
【发布时间】:2012-04-09 19:37:53
【问题描述】:

我在使用 Selenium 和 Python 中的 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")]')

【问题讨论】:

    标签: python google-chrome selenium webdriver


    【解决方案1】:

    我讨厌这样简单的事情就在你面前。

    clickme = browser.find_element_by_xpath('//a[contains(@href,"http://example.com/link")]')
    clickme.click()
    

    【讨论】:

    • 也许是因为他不知道。这就是他问的原因。
    • @dannyroa hehe..问和回答的人都是一样的:P
    猜你喜欢
    • 1970-01-01
    • 2022-01-28
    • 1970-01-01
    • 2018-01-22
    • 2022-11-21
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2016-09-29
    相关资源
    最近更新 更多