【问题标题】:Click method on Selenium 2.40.2 does not workSelenium 2.40.2 上的单击方法不起作用
【发布时间】:2014-07-23 14:14:50
【问题描述】:

我正在使用 Selenium 2.40.2 来测试 Web 应用程序。我需要鼠标移动并点击在谷歌地图上绘制一个多边形。

代码如下:

    bottom_label = browser_drive.find_element_by_xpath("//span[text()='Project']")
    time.sleep(2)
    drawing = ActionChains(browser_drive)\
                    .move_to_element(bottom_label)\
                    .move_by_offset(-650, -600)\
                    .click()\
                    .move_by_offset(100, -100)\
                    .click()\
                    .move_by_offset(300, 0)\
                    .click()\
                    .move_by_offset(0, 400)\
                    .click()\
                    .move_by_offset(-50, -50)\
                    .double_click()\
                    .perform()
    drawing.perform()
    time.sleep(2)

bottom_label 用于将鼠标指向网页末尾然后休眠以重新开始更改偏移量,单击并关闭多边形。

这个带有 Selenium 版本的代码可能不起作用。如何通过移动并单击鼠标绘制多边形?

【问题讨论】:

标签: python-3.x selenium-webdriver


【解决方案1】:

考虑使用 FluentWait、ImplicityWait 和 setScriptsTimeout 代替睡眠。

查看更多文档

http://selenium.googlecode.com/svn/trunk/docs/api/java/org/openqa/selenium/WebDriver.Timeouts.html

【讨论】:

  • 谢谢。它代替睡眠很有用
【解决方案2】:

问题出在新版本的 Selenium 和 Firefox 上。

我换了Chrome驱动,点击功能正常。

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 2014-01-12
    • 1970-01-01
    • 2022-01-19
    • 1970-01-01
    • 1970-01-01
    • 2016-07-22
    • 1970-01-01
    • 2017-05-23
    相关资源
    最近更新 更多