Home  >  Blog  >   Selenium

Synchronisation commands - SELENIUM

Rating: 4
  
 
2855
  1. Share:
Selenium Articles

waitFor and Pause  Both are synchronization commands.

waitForPageToLoad(timeout)

Arguments:

  • timeout – a timeout in milliseconds, after which this command will return with an error

Waits for a new page to load.

You can use this command instead of the “AndWait” suffixes, “clickAndWait”, “selectAndWait”, “typeAndWait” etc. (which are only available in the JS API).
Selenium constantly keeps track of new pages loading, and sets a “newPageLoaded” flag when it first notices a page load. Running any other Selenium command after turns the flag to false. Hence, if you want to wait for a page to load, you must wait immediately after a Selenium command that caused a page-load.
Pause:


pause(waitTime)

Arguments:

  • waitTime – the amount of time to sleep (in milliseconds) Wait for the specified amount of time (in milliseconds).

Difference

If pages loads before the time it will continue to next step.
Pause:—Will pause test until the specified time

Pausing test in the middle

If you want to pause test case in middle follow the below steps:
Let’s say there are 6 commands in your script and you want to pause your script at 3rd command.
Right click on command 3 and select Toggle/Break Point. Automatically you can see pause symbol in the test case pane. Your test will be paused at command 3. If you want to remove the pause repeat the same step. Pause symbol should be removed.

MindMajix YouTube Channel

Set/Clear Start Point

If you want to execute a script from middle follow below steps:
Let’s say there are 6 commands in your script and you want to start your script from 3rd command.
Right click on command 3 and select set/clear start point. Automatically you can see RUN Symbol in the test case pane. If you start running the script. Your test will be start running from command 3. If you want to remove the start point repeat the above step. RUN symbol should be removed.

Checkout Selenium Interview Questions

Execute script from specific point

If you want to execute a single command in script from middle follow below steps:
Let’s say there are 6 commands in your script and you want to execute 3rd command.
Right click on command 3 and select Execute this command. Automatically that command will be executed. Or you can double click on that command. Command will be executed

Join our newsletter
inbox

Stay updated with our newsletter, packed with Tutorials, Interview Questions, How-to's, Tips & Tricks, Latest Trends & Updates, and more ➤ Straight to your inbox!

Course Schedule
NameDates
Selenium Training Apr 27 to May 12View Details
Selenium Training Apr 30 to May 15View Details
Selenium Training May 04 to May 19View Details
Selenium Training May 07 to May 22View Details
Last updated: 03 Apr 2023
About Author

 

Madhuri is a Senior Content Creator at MindMajix. She has written about a range of different topics on various technologies, which include, Splunk, Tensorflow, Selenium, and CEH. She spends most of her time researching on technology, and startups. Connect with her via LinkedIn and Twitter .

read more
Recommended Courses

1 / 15