How to get a Text from alert?

Hello Everyone,

How to get a Text from alerts ? I’m using below methods but it is not working. Can anyone please help me to find out solution for this?

driver.swithchTo().getText();
driver.SwitchTo().alert().accept();

Hope you’ll directly get text attribute value from Alert if it is identified by UIAutomatorViewer.

Have a try and if still you are unable to handle this, attach screenshots here accordingly.

Regards,
Bhaskar.

Alert’s are no more different than general elements, we can get the text from the elements as usual.