Reputation: 405
What would be the Webdriver equivalent for assertconfirmation ? I have following selenium IDE code which when exported to JUnit 4 (Webdriver) returns an error:
IDE code:
<tr>
<td>click</td>
<td>link=Logout</td>
<td></td>
</tr>
<tr>
<td>assertConfirmation</td>
<td>Are you sure you want to logout?</td>
<td></td>
</tr>
Exported Webdriver code which corresponds to above:
@Test
public void testUntitled2() throws Exception {
driver.findElement(By.linkText("Logout")).click();
// ERROR: Caught exception [ERROR: Unsupported command [getConfirmation]]
}
I use to be able to successfully use the following with RC but with webdriver it no longer works - (please note I am trying to migrate my scripts to webdriver)
assertTrue(selenium.getConfirmation().matches("^Are you sure you want to logout[\\s\\S]$"));
Cheers
Shan
Upvotes: 2
Views: 4368
Reputation: 38424
This should be it!
final String text = "Are you sure you want to logout?";
assertTrue(driver.switchTo().alert().getText().equals(text));
...or maybe the 'matches()' version you got there.
Upvotes: 4