2014-11-14 166 views
1

我正在使用Robot Framework IDE和Selenium2Library。點擊鏈接打開新的瀏覽器窗口

現在我的問題:

我的測試打開Firefox並進入一個頁面。在這個頁面上是一個鏈接。我必須點擊鏈接並在新頁面上繼續測試。但鏈接不會在同一個瀏覽器窗口中打開。我嘗試使用關鍵字「選擇窗口」與url=https//...(即在新瀏覽器窗口中打開的頁面的URL)到達新窗口,但本地化仍在第一個瀏覽器窗口中。我也嘗試了關鍵字「切換瀏覽器」與第二個窗口的網址,但它不工作。

有沒有人有一個想法,我可以切換到其他瀏覽器窗口?

另一個想法是獲取鏈接的URL,並通過關鍵字「打開瀏覽器」在新的瀏覽器窗口中打開它。但我不知道如何獲得鏈接的網址?

+1

有一種方法可以使用selenium webdriver切換到新窗口。這是[鏈接](http://stackoverflow.com/a/9597714/4193730) – Subh 2014-11-14 15:31:08

回答

4

嘗試切換到基於它的新窗口的標題:

Select Window title=<Title of the new window> 

您可以窗口標題中使用得 - Get Window Titles

0

我有同樣的問題。這裏有一個解決方案:

${exportlink}= Get Element Attribute [email protected]   
Log ${exportlink}   
sleep 2   
${exportwindow}= Replace String url=ExportLink ExportLink    ${exportlink} 
Log ${exportwindow}   
Go to ${exportlink}   
Select Window ${exportwindow}   
Wait Until Page Contains Element xpath=/html/body 300  
Wait Until Page Contains Export is completed. 300  
相關問題