简体   繁体   中英

How to automate 'Toast Message' using robot framework?

In my web application (Python/Django) there are two different toast messages for error and success of the action. Text contents on both toasts are different for different action results and location of displaying is also multiple (Left corner/Right corner/Header/Footer, etc). It displays for 3 seconds and then disappeared in fading mode.

How to automate it using robot framework as there is no fixed locators?

You can use Wait until element is visible , giving it a locator unique to the message.

For example, let's assume the toast is implemented as a div that looks like this:

<div class='toast'>Record submitted</div>

You could use the keyword like this:

Wait until element is visible  
...  //div[contains(@class, 'toast') and text()='Record submitted']

You could also just wait for the toast element to appear, get the text, and then assert on the text.

Wait until element is visible  //div[contains(@class, 'toast')]
${message}=  Get text  //div[contains(@class, 'toast')]
Should be equal  ${message}  Record submitted

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM