Answered

Variable of "GET_WEB_VALUE" is set to null when the locator doesn't exist. However, it should fail with "Locator not found" message

When "GET_WEB_VALUE" command is used and the element is not found, the variable is set to BLANK. However the step should be failed so when looking in the results, we know which step is exactly the issue. Otherwise the failure will be some where else when "Compare" step is used.

I know we can use the "VERIFY_ELEMENT" command before the "GET_WEB_VALUE" if the verification of the element existing is done part of GET_WEB_VALUE, it's more efficient.

0
3 comments
Avatar
Joseph Hamdan

Hasib,This is by design. Basically we don’t fail the step if there is nothing found because it’s not a failure. It can be used for cases where users wants to act on an element not be present. In short, the user may want to do IF (data doesn’t exist) Then do ….. It’s similar to SQL, where your query returns null but doesn’t fail. As an alternative method, you can use:
1. get_web_value
2. if (value doesn’t exist)
3. assert failure
4. get_web_value
5. if (value exists)
6. do (action)

0
Comment actions Permalink
Avatar
William Smith

So, what is the syntax for the if statement to determine if (value doesn't exist)

If I do a

           if @value NOT_EQUAL null

That doesn't seem to work.   It treats the null as a word and of course the expression is true instead of false.

0
Comment actions Permalink
Avatar
Joseph Hamdan

Hi William,

This variable can be used for non existing values: @system.empty

Example:

WEB VALUE_GET RESULT_VARIABLE value SOURCE JAVA_SCRIPT "const value = 'test'\nconsole.log(value)\n// return value" HALT ON ERROR

IF @value EQUAL @system.empty AS TEXT

WRITE TEXT "Value is empty" OUTPUT CONSOLE HALT ON ERROR

IF_END

Regards,
Subject7 Team

0
Comment actions Permalink

Please sign in to leave a comment.