2014-01-09 22 views
0

我正在通過selenium-webdriver測試我的測試用例。我的網絡應用程序有一些像點擊,選擇等操作。我已經使用selenium.click()方法。在測試結束時,我想自動關閉一個彈出窗口。是否有任何方法來關閉Selenium類中的彈出窗口或瀏覽器?請幫助我是初學者硒測試的webdriver。我使用硒服務器2.37.0和瀏覽器是IE瀏覽器。Selenium測試結束時是否有Selenium類中的任何方法關閉瀏覽器?

這裏是我的代碼片段:

namespace SeleniumTests 
{     
    // this is my test method   
    [TestMethod] 
    public void TheJan6Test() 
    { 
     selenium = new DefaultSelenium("localhost", 4444, "*iexplore", "http://rcm-bpmt.apmoller.net"); 
     selenium.Start(); 
     verificationErrors = new StringBuilder(); 
     selenium.Open("workspace/faces/jsf/workspace/workspace.xhtml"); 


     // Here the steps regarding the automation of browser 
     selenium.Type("id=portletComponentWorkList_viewNormalModeWorkList_viewPanel_conditionsTableSearch__OCID0__input", "198545"); 
     selenium.Click("id=portletComponentWorkList_viewNormalModeWorkList_viewPanel_searchWorkList"); 
     selenium.Click("id=portletComponentWorkList:viewNormalModeWorkList:viewPanel:instanceListTableWorkList:_OCID1_:executeLabel"); 

     //I want to close the popup after this step 
     //At the end of test i want to close the one popup window automatically.Is there is any method to close the popup window or browser in Selenium Class 
    } 
} 

請幫助我如何關閉彈出在試驗結束。

+0

谷歌有大量的資源讓你找到那裏。你嘗試過搜索嗎? – sircapsalot

+1

這需要更多的上下文。彈出窗口可以有很多功能,例如基本的JS彈出窗口,jQuery模式對話框,一些瘋狂的HTML5彈出窗口或物理瀏覽器窗口。那它是什麼?給我們更多關於應用程序的背景。此外,您正在使用Selenium的舊版(Selenium RC)版本。 – Arran

回答

1

可能這會幫助你

[TearDown] 
public void cleanup() 
{ 
    driver.Close(); 
} 
相關問題