Toast alert capturing


I want to capture text in toast message. as mentioned in the below snapshot toast alert(blue color arrow) is displaying when click on the icon(red color arrow). How to capture that text in the alert.

I tried as below.but unable to make it.'Datalocker/Databox/DataboxDollarIcon'))
if (elementPresent==true) {
WebDriver driver = DriverFactory.getWebDriver()
String AlertText = driver.switchTo().alert().getText()
print '============'
/*WebUI.verifyEqual(AlertText, 'Success!')


This doesn’t look like standard browser alert, so it could be HTML element. Just open a browser console and try to capture it while it is displayed.


Hi @Marek_Melocik…Actullay it is not a HTML element. Thats why i can’t capture it.


Can you share your HTML code of the page with toast message?


Actually it doesn’t have HTML code. It has created using Angular library.(


I get it, but there must be an element, which is displayed as soon as show message function is called. Try to look for an element which contains the message text.


Okay…I’ll try :grinning:


Below code should get the text of the toast message. You just need to capture the correct HTML for the toast message.


WebUI.maximizeWindow()"Page_angular-toastr examples/button_Open Toast"))

KeywordUtil.logInfo( WebUI.getText(findTestObject("Page_angular-toastr examples/div_Success"), FailureHandling.STOP_ON_FAILURE) )

I have used website to replicate your toast message. Once the toast message is triggered, html for the same would be added to the DOM. You can use Chropath for getting the correct object to get its XPath.

In my case it was //div[@class='toast-message']