How to Use Selenium IDE "waitForText" and "waitForNotText" commands?

"waitFor" commands of selenium IDE are very useful for your software application regression testing. There are many waitFor commands available in selenium IDE like - "waitForElementPresent " command will pause selenium until targeted element not present on software web application page,
 "waitForPageToLoad" command will force selenium to pause until page not get loaded properly. Same way, "waitForText" and "waitForNotText" commands are works with text of software application web page. When you need selenium wait until text present then you can use waitForText command. Selenium will wait for text to appear on page using it. Let me describe both of them.

"waitForText" Command

"waitForText" will wait for the text to be present on targeted element. Selenium wait for text will pause selenium until expected text not present on targeted element. Once targeted element gets expected text, selenium IDE execution will be resumed. Selenium wait until text present can be done using waitForText command.

"waitForNotText" Command

Opposite to "waitForText" Command, "waitForNotText" Command will wait for specified text to be not present on targeted element. Once text from targeted element disappeared, next command will be executed.

Let we take simple example for both the commands.

New Test
CommandTargetValue
openhttp://only-testing-blog.blogspot.com/2013/09/test.html
waitForNotTextcss=#timeLeftTime left:*
clickAndWaitcss=#submitButton
waitForTextcss=#timeLeftReady!
clickAndWaitcss=#submitButton

View waitForText Example In WebDriver

Look in to above example, "waitForNotText" command will wait for text 'Time left:*'(We can use * at the beginning or in between or at the end of sentence if string value is dynamic.) to disappear from targeted element. Once that text disappear, selenium will execute next command. Same way, selenium wait for text command will wait for text 'Ready!' to be present on targeted element. Selenium wait for text to appear on page.

First run above example in selenium IDE and then create same test case for your software web application.

No comments:

Post a Comment