【问题标题】:mouse_move_to DEPRECATED ruby selenium cucumbermouse_move_to 已弃用的红宝石硒黄瓜
【发布时间】:2019-04-27 03:09:16
【问题描述】:

我是 Selenium 的新手,想将鼠标悬停在类别按钮上,然后单击提供的下拉菜单中的子类别。我之前使用过“mouse_move to”命令,但现在它说:WARN Selenium [DEPRECATION] Driver#mouse is deprecated。请改用 driver.action..perform。 我尝试使用此代码将“鼠标”更改为“操作”并将“单击”更改为“执行”,但它不起作用。

 element = $driver.find_element :xpath => "//span[@class = 'ls_2px' and text() = 'Accessories']"
  $driver.mouse.move_to element
 element = $driver.find_element :xpath => "(//div[@class = 'vt'][.//a[text() = 'View All']]//a[0])"
  element.click
 end

我需要将 WebDriver::W3CActionBuilder 添加到我的 env 文件吗? 我只有这个:

require 'rubygems'
require 'selenium-webdriver'
require 'cucumber'
$driver = Selenium::WebDriver.for :chrome
$dropdown = Selenium::WebDriver::Support::Select

【问题讨论】:

  • 嗨,不要直接使用 SeleniumBinding 如果您要使用 Ruby 绑定,请使用 WATIR,它是 selenium Ruby 绑定的包装器。并在 WATIR 中尝试,如果您之后有任何问题,请使用 WATIR 标签发布问题。
  • 对于 Ruby,我建议使用 Capybara,它可以与包括 selenium 在内的各种驱动程序一起使用。它为大多数网络操作提供了更简单的方法。

标签: ruby selenium-webdriver cucumber rubymine webautomation


【解决方案1】:

driver.action.move_to(element).perform 在这种情况下应该适用于Hover

资源:Class: Selenium::WebDriver::ActionBuilder - move_to

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2017-03-22
    • 1970-01-01
    • 1970-01-01
    • 2013-06-17
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多