cancel
Showing results for 
Search instead for 
Did you mean: 

Xpath compare whole NOBR

SOLVED
Highlighted
Contributor

Xpath compare whole NOBR

i have element structrure like this :

 

<td class="csC31EF637" >

           <nobr>INVRCT-</nobr><br><nobr>4072</nobr>

</td>

 

 

i wanted to query the inside as one like this 

 

//td[@class="csC31EF637"]/nobr[text()="INVRCT-4072"]

 

somehow this is not working

Tags (3)
1 ACCEPTED SOLUTION

Accepted Solutions
Highlighted
Contributor

Re: Xpath compare whole NOBR

if you use /nobr you'll see there are two, on the same level you can't have both, you need to go to parent (<td>):

 

//td[@class="csC31EF637" and text()="INVRCT-")]
//td[@class="csC31EF637" and text()="4072")]

 

 

I usually do a print of the innerHTML attribute if I'm unsure:

 

els = driver.find_elements(By.XPATH, "//td[@class='csC31EF637']/nobr")
for el in els:
    print(el.get_attribute('innerHTML'))

 

 

 

View solution in original post

2 REPLIES 2
Highlighted
Contributor

Re: Xpath compare whole NOBR

if you use /nobr you'll see there are two, on the same level you can't have both, you need to go to parent (<td>):

 

//td[@class="csC31EF637" and text()="INVRCT-")]
//td[@class="csC31EF637" and text()="4072")]

 

 

I usually do a print of the innerHTML attribute if I'm unsure:

 

els = driver.find_elements(By.XPATH, "//td[@class='csC31EF637']/nobr")
for el in els:
    print(el.get_attribute('innerHTML'))

 

 

 

View solution in original post

Highlighted
Community Manager

Re: Xpath compare whole NOBR

Thank you for helping mortenb123!

 

Hi @longchasen ! Have you tried the suggestion yet? Please let us know how it went🙂


Sonya Mihaljova
Community and Education Specialist

Did my reply answer your question? Give Kudos or Accept it as a Solution to help others. ⬇️⬇️⬇️
New Here?
Join us and watch the welcome video:
Announcements
Top Kudoed Authors