I need to grab a text from the alert box shown below. This alert box appears hovering above the url bar. Below is an example of my framework assertion:
verifyDisplay("'"+ driver.switchTo().alert().getText() + "'", By.xpath("xpath").
I am not sure, how to grab xpath
, id
, name
of this alert box, since there is none.
Any help is greatly appreciated.
There is a method in Alert interface which gives you the text of the alert box message. As below:
Alert alert = driver.switchTo().alert();
alert.getText();
Alert API javadoc
Let me know if you need further help.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With