My scenario is that I have 2 windows, and the 2nd one shows an alert dialog of which I wanna check it's text.
Now I switch my WebDriver to the second window via:
driver.switchTo().window(driver.getWindowHandles().iterator().next())
And then to make sure I get the correct Alert handle I use:
Alert alert = ExpectedConditions.alertIsPresent().apply(driver);
String text = alert.getText();
but text is null
even though the alert clearly contains a lot of text.
I then tried to use
String text = driver.switchTo().alert().getText();
but it also returns null
.
Anybody of you encountered this problem?
I have another alert dialog I'm checking but that test runs smooth, so I
guess it's related to my 2 windows, found a smiliar post in webdriver Google
Group but nobody has replied to it. I also tried to close the other window
and then check for the alert, but same result. The alert is present and
recognized, otherwise alert
would have been null
.