check toast message

138 views
Skip to first unread message

Fabio Rafaelli

unread,
Jul 2, 2020, 4:01:17 AM7/2/20
to Selenium Users
Hi all
How can i be sure that this element (Toast message) appear on the screen and get the message within it?
Best regards
Fabio

Fabio Rafaelli

unread,
Jul 2, 2020, 4:04:03 AM7/2/20
to Selenium Users
The element is :

<span class="toastMessage slds-text-heading--small forceActionsText" data-aura-rendered-by="3183:0" data-aura-class="forceActionsText">Opportunity <!--render facet: 3191:0--><a href="javascript:void(0)" title="aaa" data-aura-rendered-by="3206:0" class="forceActionLink" data-aura-class="forceActionLink"><div title="aaa" data-aura-rendered-by="3207:0">aaa</div></a> was created.</span>

Gokul krishna

unread,
Jul 2, 2020, 4:07:01 AM7/2/20
to seleniu...@googlegroups.com
You can try to driver.getPageSource() just at the time when the toast message appears and check if the returned page source contains toast message text.
  There might be better ways to do it. May be the experts in the group can share more inputs.

--
You received this message because you are subscribed to the Google Groups "Selenium Users" group.
To unsubscribe from this group and stop receiving emails from it, send an email to selenium-user...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/selenium-users/679a3dd2-84cb-43a3-8275-06c7ec60c147o%40googlegroups.com.

Hanumantha Reddy

unread,
Jul 2, 2020, 10:57:45 AM7/2/20
to Selenium Users
You can wait for the element visible. This can be achieved by used WebDriverWait object. You can follow below code,

            WebDriverWait wait = new WebDriverWait(driver, TimeSpan.FromSeconds(12));
            wait.Until(ExpectedConditions.ElementExists(By.ClassName("forceActionLink")));

For more information on WebDriverWait and how to use, you can follow below video.


Disclaimer : I support the channel of the video link I shared  

Gabriel Tardif

unread,
Jul 2, 2020, 4:02:37 PM7/2/20
to Selenium Users
element = WebDriverWait(driver, 10).until(EC.presence_of_element_located((By.CLASS_NAME, "toastMessage slds-text-heading--small forceActionsText"))

If the language you are using is python I will suggest something like above.
Or you can check this website https://selenium-python.readthedocs.io/waits.html
Or this one for accurate documentation https://www.selenium.dev/selenium/docs/api/py/webdriver_support/selenium.webdriver.support.expected_conditions.html?highlight=expected
Reply all
Reply to author
Forward
0 new messages