selenium

Catchpoint pause vs. waitForNoRequest - What's the difference?


I have a test that was alerting because it was taking extra time for an asset to load. We changed from waitForNoRequest to a pause (at Catchpoint's suggestion). That did not seem to have the expected effect of waiting for things to load. We increased the pause from 3000 to 12000 and that helped to allow the page to load and stop the alert. We noticed some more alerts, so I tried to increase the pause to something like 45000 and it would not allow me to pause for that long.

So the main question here is - what functionality does both of these different features provide? What do I gain by pausing instead of waiting, if anything?

Here's the test, data changed to protect company specific info. Step 3 is where we had some failures and we switched between pause and wait.

// Step - 1
open("https://website.com/")
waitForNoRequest("2000")
click("//*[@id=\"userid\"]")
type("//*[@id=\"userid\"]", "${username}")
setStepName("Step1-Login-")

// Step - 2
clickMouseAndWait("//*[@id=\"continue\"]")
waitForVisible("//*[@id=\"challenge-password\"]")
click("//*[@id=\"challenge-password\"]")
type("//*[@id=\"challenge-password\"]", "${password}")
setStepName("Step2-Login-creds")

// Step - 3
clickMouseAndWait("//*[@id=\"signIn\"]")
setStepName("Step3-dashboard")
waitForTitle("Dashboard")
waitForNoRequest("3000")
click("//*[@id=\"account-header-wrapper\"]")
waitForVisible("//*[@id=\"logout-link\"]")
click("//*[@id=\"logout-link\"]")

// Step - 4
clickAndWait("//*[text()=\"Sign Out\"]")
waitForTitle("Login - ")
verifyTextPresent("You have been logged out.")
setStepName("Step5-Logout")

Solution

  • Rachana here, I’m a member of the Technical Service Team here at Catchpoint, I’ll be happy to answer your questions.

    Please find the differences below between waitForNoRequest and Pause commands:

    Pause Purpose: This command pauses the script execution for a specified amount of time, whether there are HTTP/s requests downloading or not. Time value is provided in milliseconds, it can range between 100 to 30,000 ms.

    Explanation: This command is used when the agent needs to wait for a set amount of time and this is not impacted by the way the requests are loaded before proceeding to the next step or command. Only a parameter is required for this action.

    WaitForNoRequest Purpose: This commands waits for a specified amount of time, when there was no HTTP/s requests downloading. The wait time parameter can range between 1,000 to 5,000 ms.

    Explanation: The only parameter for this action is a wait time. The agent will wait for that specified amount of time before moving onto the next step/command. Which will, in return, allow necessary requests more time to load after document complete.

    For instance when you add waitforNoRequest(5000), initially agent waits 5000 ms after doc complete for any network activity. During that period if there is any network activity, then the agent waits another 5000 ms for the next network activity to end and the process goes on until no other request loads within the specified timeframe(5000 ms).

    A pause command with 12000 ms, gives exactly 12 seconds to load the page. After 12 seconds the script execution will continue to next command no matter the page is loaded or not.

    Since waitForNoRequest has a max time value of 5000 ms, you can tell the agent to wait for a gap of 5 seconds when there is no network activity. In this case, the page did not have any network activity for 3 seconds and hence proceeded to the next action. The page was not loaded completely and the script failed.

    I tried to increase the pause to something like 45000 and it would not allow me to pause for that long. We allow a maximum of 30 seconds pause time hence 45 seconds will not work.

    Please reach out to our support team and we’ll be glad to connect you with our scripting SMEs and help you with any scripting needs you might have.