Jump to content

Recommended Posts

Posted

Hello,

I am using Webdriver UDF using edge browser. Below is my html elements

<tr data-location="abc"

<td class=""></i><br><span class="efg"> <i data-clipboardtext="hij" class="lmn"></i> <i class="nop"></i> <i class="qrs"></i></span></td>

<td class="tuv" style="wxy">-</td>

<td class="123"><span class="456"><i class="789"></i></span></td>

</tr>

i want to match the the two path if <tr data-location="abc" and span class="456" then fine or else error. I tried the below _WD_WaitElement script  but not sure if its correct path way. So i just need to confirm if my below script will match both tr & span data or not.

$sElement = _WD_WaitElement($sSession, $_WD_LOCATOR_ByXPath, "//tr[@data-location='abc']//td/span[@class='456']")

 

Posted

google is your friend:

https://www.w3schools.com/xml/xpath_operators.asp

check both following examples:

$sElement = _WD_WaitElement($sSession, $_WD_LOCATOR_ByXPath, "//tr[@data-location='abc'] | //td/span[@class='456']")
$sElement = _WD_WaitElement($sSession, $_WD_LOCATOR_ByXPath, "//tr[@data-location='abc'] or //td/span[@class='456']")

 

Signature beginning:
Please remember: "AutoIt"..... *  Wondering who uses AutoIt and what it can be used for ? * Forum Rules *
ADO.au3 UDF * POP3.au3 UDF * XML.au3 UDF * IE on Windows 11 * How to ask ChatGPT for AutoIt Codefor other useful stuff click the following button:

  Reveal hidden contents

Signature last update: 2023-04-24

Posted

Thanks..So i am using the below so according to me first it will check the //tr[@data-location='abc'] and after that it will check the  span[@class='456'] under tr[@data-location='abc'] correct? and if under //tr[@data-location='abc'] span changes fron 456 to 627, it should give me the error. Correct me if i am wrong.

$sElement = _WD_WaitElement($sSession, $_WD_LOCATOR_ByXPath, "//tr[@data-location='abc'] | //td/span[@class='456']")
Posted

One important thing to remember is that most (all?) Webdriver implementations only support xpath 1.0. Some of the information you find on the web may not apply as it is geared towards xpath 2.0 / 3.0.

Have you tried writing the xpath like this?

$sElement = _WD_FindElement($sSession, $_WD_LOCATOR_ByXPath, "//tr[@data-location='abc']/td/span[@class='456']")

 

Posted

Hello Dan,

it will work with _WD_WaitElement correct?

$sElement = _WD_WaitElement($sSession, $_WD_LOCATOR_ByXPath, "//tr[@data-location='abc']/td/span[@class='456']")
Posted

Hello Dan,

I tried with below and its working fine. I will do testing more and let you know. Thanks

$sElement = _WD_WaitElement($sSession, $_WD_LOCATOR_ByXPath, "//tr[@data-location='abc']/td/span[@class='456']")

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...