It would be nice if WebUI could provide something like the answer I proposed in this post natively.
The sentinel name would need to be more robust using perhaps a uuid-based name.
String jsSentinelTest = 'return something !== ""';
String sentinel = WebUI.startSentinel("russ", jsSentinelTest)
WebUI.waitSentinel(sentinel, TIMEOUT_SECONDS)
jsSentinelTest
can be as complex as required.
String sentinel
becomes "russ" + uuid
(without hyphens maybe)
WebUI.waitSentinel
waits max TIMEOUT_SECONDS for jsSentinelTest
to return true
.
WebUI.startSentinel
sets up the sentinel value on the browser’s window object (if needed, because the jsSentinelTest
may be enough).
Formally
Code | Comment |
---|---|
jsSentinelTest |
Executable JavaScript string which returns true when a process is complete. |
WebUI.startSentinel(String name, String jsSentinelTest) |
Sets up a sentinel with the given name. Returns the fully qualified name: name+uuid
|
WebUI.waitSentinel(String name, int timeout = 20) |
Waits until the named sentinel returns true. |
WebUI.waitSentinel(String name, int timeout = 20, int initialDelay = 0) |
Pauses initialDelay seconds then waits until the named sentinel returns true. |
I wrote this off the top of my head when the idea struck me - it could be complete nonsense or I may have missed something
Note: You may prefer state everywhere I stated sentinel (waitState, etc). I prefer sentinel, it’s more generic.