2013-03-22 81 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

相關問題