In your macro, there is no command that triggers a page load started event (e. g. OPEN does this, or a click on something that opens a new page). And without a page load start event, waitForPageToLoad
has nothing to do (as it waits for page load completed event).
Yes, I see that you understand the point of my macro, there is nothing to trigger a page load event.
But now you explained something new to me. Let me check if I understand by restating using different words: ‘waitForPageToLoad’ will not wait for anything unless there is a page load started event. Only after detecting that a page load start event occurred will ‘waitForPageToLoad’ wait until timeout or until a page load complete event occurs.
If you want to wait in such a case, I recommend to use the XClick (Image for which to wait for)
command. In this case XClick waits until the image shows up - or the timeout time is reached.
I made two scripts to check my understanding:
{
“Name”: “Try 1”,
“CreationDate”: “2019-11-4”,
“Commands”: [
{
“Command”: “open”,
“Target”: “https://news.google.com/?hl=en-US&gl=US&ceid=US:en”,
“Value”: “”
}
]
}
{
“Name”: “Try 2”,
“CreationDate”: “2019-11-4”,
“Commands”: [
{
“Command”: “open”,
“Target”: “https://news.google.com/?hl=en-US&gl=US&ceid=US:en”,
“Value”: “”
},
{
“Command”: “waitForPageToLoad”,
“Target”: “15000”,
“Value”: “”
}
]
}
Here is the log when I run the two scripts:
[status] Playing macro Try 1
[info] Executing: | open | https://news.google.com/?hl=en-US&gl=US&ceid=US:en | |
[info] Macro completed (Runtime 3.00s)
[status] Playing macro Try 1
[info] Executing: | open | https://news.google.com/?hl=en-US&gl=US&ceid=US:en | |
[info] Macro completed (Runtime 2.87s)
[status] Playing macro Try 1
[info] Executing: | open | https://news.google.com/?hl=en-US&gl=US&ceid=US:en | |
[info] Macro completed (Runtime 4.09s)
[status] Playing macro Try 2
[info] Executing: | open | https://news.google.com/?hl=en-US&gl=US&ceid=US:en | |
[info] Executing: | waitForPageToLoad | 15000 | |
[info] Macro completed (Runtime 3.31s)
[status] Playing macro Try 2
[info] Executing: | open | https://news.google.com/?hl=en-US&gl=US&ceid=US:en | |
[info] Executing: | waitForPageToLoad | 15000 | |
[info] Macro completed (Runtime 3.21s)
[status] Playing macro Try 2
[info] Executing: | open | https://news.google.com/?hl=en-US&gl=US&ceid=US:en | |
[info] Executing: | waitForPageToLoad | 15000 | |
[info] Macro completed (Runtime 3.01s)
So, I don’t know because Try 1 and Try 2 have very close average times of 3.32 and 3.18. I was hoping to see that waitForPageToLoad should slow down the script since waitForPageToLoad is going to wait until the page finishes loading before going on. But if anything, waitForPageToLoad sped up the script because the average time is very slightly shorter. But the difference is almost nothing and might be explained with the randomness of page load times.
I probably picked a bad test URL. And/or I still don’t understand what waitForPageToLoad is supposed to do.