2014-02-21 52 views
0

能夠接近警戒我有下拉,從下拉菜單中選擇值,選擇是有平變化JavaScript函數,它將引發警報窗口。我不是在硒能接近警報。我不是硒

回答

0

手柄警報使用下面的代碼:

@Test 
public void testAlertOk() 
{ 
    //Now we would click on AlertButton 

    try { 
     //Now once we hit AlertButton we get the alert 
     Alert alert = driver.switchTo().alert(); 
     //Text displayed on Alert using getText() method of Alert class 
     String AlertText = alert.getText(); 
     //accept() method of Alert Class is used for ok button 
     alert.accept(); 
     //Verify Alert displayed correct message to user 
     assertEquals("this is alert box",AlertText); 
    } catch (Exception e) { 
     e.printStackTrace(); 
    } 
} 
0

如果我讀這個權利,你是不是在找收納於警報什麼,只是周圍的警報的方式,並繼續進行測試。

try 
{ 
    driver.SwitchTo().Alert().Accept(); 
    //driver.SwitchTo().Alert().Dismiss(); 
} 
catch (NoAlertPresentException) 
{ 

}