If Object exists - Script and Keyword
The IF Object in either script or Keywords tests is not reliable for me.
When using ".Exists" or KW equivalent the code will execute and may bring back the correct results but the issue is the test will ALWAYS fail
a button on my screen is called "clickMe" (for this example we can call the whole Name mapping "clickMe")
"Found the button"
"Button has not been found"
CASE: Button exists: SUCCESS
If the button exists the test will proceed to click the button
CASE: Button does NOT exist: FAIL
If Object fails and the button will NOT be clicked
Issue, on the failed case, the test executes as expected but the Log will show an error on what would be a positive test
- when I am running regression tests (380+) I can't have all the tests failing when in fact everything has passed (even 1 case this is unacceptable functionality)
This has forced me to instruct my team NOT to use this functionality and it has rendered over 100 tests back to labour intensive manual testing
I've always found this annoying and confusing. When using Exists, we're checking the objects property value is either true or false (the object must not be null). But to validate the object state, you may need to check if the object exists in the system. Using the appropriate WaitNNN method, such as WaitChild method, gets around this problem.
Here's an example, using WaitChild to find a button which doesn't exist.
It's not possible to use,
if (btn !== null) // or if (btn != null)
because WaitChild method is returning a stub object, btn will not be null.