2013-03-22 87 views
1

使用Selenium IDE,我已经导出了一个基本测试,它将登录到一个帐户,鼠标悬停在下拉列表中,并找到注销按钮。测试结束。Selenium Webdriver - Ruby不支持的命令

,我看到的问题是,当测试红宝石/测试::单位/网络驱动程序中导出我的前一个命令waitForPopUp不支持,并返回

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

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

回答

4

将使用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 

要了解更多关于Ruby绑定(在DSL)的硒webdriver的,你可以在了解他们官方维基页面:http://code.google.com/p/selenium/wiki/RubyBindings

相关问题