2012-04-16 89 views
2

什麼是Webdriver相當於assertconfirmation? 我具有以下其中當出口JUnit 4中(的webdriver)硒IDE代碼返回一個錯誤:什麼是webdriver等價於assertconfirmation?

IDE代碼:

@Test 
    public void testUntitled2() throws Exception { 
     driver.findElement(By.linkText("Logout")).click(); 
     // ERROR: Caught exception [ERROR: Unsupported command [getConfirmation]] 
    } 

I:

,其對應於上述 ​​

導出的webdriver代碼使用能夠成功地使用以下與RC但使用webdriver它不再工作 - (請注意我試圖將我的腳本遷移到webdriver)

assertTrue(selenium.getConfirmation().matches("^Are you sure you want to logout[\\s\\S]$")); 

乾杯

回答

4

這應該是它!

final String text = "Are you sure you want to logout?"; 
assertTrue(driver.switchTo().alert().getText().equals(text)); 

...或者也許是 '匹配()' 版本,你到了那裏。

switchTo()

alert()

getText()

+1

這已經完美工作 - 謝謝 – user929258 2012-04-17 08:26:29