0

As RF novice, i'm trying to understand a line of code which uses "Wait Until Element Is Visible" to verify a text (string of characters) exists on the HMI page or not instead of using "Element Text Should be". In my opinion the code should be:

Element Text Should be    //*[@id="tbdyonmouseover"]/tr[1]/td[1]/span   FirstName

but the actual code uses the exact same Locator with text() in this way:

Wait Until Element Is Visible  //*[@id="tbdyonmouseover"]/tr[1]/td[1]/span[text()="FirstName"]

Are they the same? Especially when i have a table of one row with several paired data , the code uses this method extensively to check that all nodes exists (Visible?) on the page. For Example, one row with 4 paired table data td

 <tbody id="grp_801body">
   <tr>
     <td class="Name"><span class="Line_Name" title="" style="">**doc. number**</span></td>
     <td class="Value" id="vv_8050755945013937879"><span class="nc-param-value" style="margin-left:0px;"><span class="Line_Value">111</span></span></td>
     <td class="Name"><span class="SpanInfoLine_Name" title="">**query number**</span></td>
     <td class="Value" id="vv_8050755945013937878"><span class="nc-param-value" style="margin-left:0px;"><span class="Line_Value">**B2_G9R7_ln8**</span></span></td>
   </tr>

To check all these four tds in one place the code uses Wait instead of Element Text Should Be in the manner explained on top:

//*[@id="tbdyonmouseover"]/tr[1]/td[1]/span[text()="doc. number"]/../..//*[@id="tbdyonmouseover"]/tr[1]/td[2]/span[text()="${Dossier_Number}"]/../..//*[@id="tbdyonmouseover"]/tr[1]/td[3]/span[text()="query number"]/../..//*[@id="tbdyonmouseover"]/tr[1]/td[4]/span[text()="${myVar}"]

Is it correct especially for several nodes of a table row?

Thank you

1 Answer 1

1

Yes, they are functionally the same - in the sense they will only pass if the text is the one you expect.
Still there are differences between them - obviously, the "Wait Until" will give some time for the string to appear (rendering, or js changing it) vs the immediate check of the other.

And another difference is the Element Text Should Be returns the visible text of the element - e.g. "close to what a user sees in their browser" , while the xpath with text()="FirstName" looks for a node with precisely this content - any whitespace around it or child nodes having portions of the string (not done in your example) will cause it to fail.

There is another difference - if the element is hidden, the selenium method used in Element Text Should Be will return an empty string (it's just how SE works), while the xpath will match it (as it doesn't "care" about visibility, it just parses xml). But that is not an issue with your example, the "Wait Until Element Is Visible" implies the check is on visualized elements.

Sign up to request clarification or add additional context in comments.

1 Comment

Thnak you very much for your help

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.