【问题标题】:Selenium Webdriver - Ruby Unsupported CommandSelenium Webdriver - Ruby 不支持的命令
【发布时间】:2013-03-22 23:21:57
【问题描述】:

使用 Selenium IDE,我导出了一个基本测试,该测试登录到一个帐户,将鼠标悬停在下拉菜单上,然后找到注销按钮。然后测试结束。

我看到的问题是,当在 ruby​​/test::unit/web 驱动程序中导出测试时,我之前的命令 waitForPopUp 不受支持并返回

# ERROR: Caught exception [ERROR: Unsupported command [waitForPopUp | _self | 30000]]

我需要 ruby​​ 翻译来导航到鼠标悬停,否则测试将超时并返回错误。另外,如果我再次遇到此问题,您是否可以将我链接到 ruby​​ webdriver 命令列表。

【问题讨论】:

    标签: ruby selenium ide webdriver


    【解决方案1】:

    在将使用 Selenium IDE 创建的测试用例导出到 Ruby 等语言时,有些命令无法完美转换。 waitForPopUp 恰好是这些命令之一。相反,您需要在代码中找到无法转换的行并编写受支持的命令来执行相同的操作。

    您可能想要使用这样的东西(未经测试的代码!):

    # This code defines the method
    def wait_for_and_switch_to_new_popup(timeout = 30) # seconds
      Selenium::WebDriver::Wait.new(:timeout => timeout,:message => "Failed to find popup within #{timeout} seconds!").until do
        @driver.window_handle != @driver.window_handles.last
      end
      @driver.switch_to.window(@driver.window_handles.last)
    end 
    
    ...
    
    # This calls the method to wait for and switch to the new popup.
    # Use this inside your code to tell the browser to switch to the new popup
    wait_for_and_switch_to_new_popup
    

    要了解有关 Selenium WebDriver 的 Ruby 绑定(DSL)的更多信息,您可以在官方 Wiki 页面上了解它们:http://code.google.com/p/selenium/wiki/RubyBindings

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2017-09-11
      • 1970-01-01
      • 2013-11-08
      • 1970-01-01
      • 2011-05-17
      • 2012-04-04
      相关资源
      最近更新 更多