How to resolve the issue: Xpath for node without text but child has text

0 votes

I am having an issue trying to find a node that does not have text, but their child has an specific text.

Here is an example of the html code:

<strong>

  This is not 

<span>the one</span>

</strong>

<strong>

<span>the one</span>

</strong>

So I need to find the second strong.. but the xpath that I am using is this one:

//strong/span[text()='the one']

This brings me the two elements ... but I need the second one.

I tried something like this:

//strong[not(text())]/span[text()='the one']

but it didn't work. Can anybody help me in this:

Jun 11, 2018 in Selenium by Martin
• 4,220 points
224 views

1 answer to this question.

0 votes

This will help you:

//strong[not(normalize-space(text()))]/span[text()='the one']

answered Jun 11, 2018 by Samarpit
• 5,130 points

Related Questions In Selenium

0 votes
1 answer

How to input text in the text box without calling the sendKeys()?

Hi Rohan, you can use Javascript Executer ...READ MORE

answered May 29 in Selenium by Abha
• 16,440 points
29 views
0 votes
1 answer
0 votes
1 answer

How can I select a particular node within the XPath node sets by index?

There is no concept of 'i' in ...READ MORE

answered Apr 20, 2018 in Selenium by king_kenny
• 3,590 points
173 views
0 votes
1 answer

Finding WebDriver element with Class Name in java

The better way to handle this element ...READ MORE

answered Apr 10, 2018 in Selenium by nsv999
• 5,050 points
259 views
0 votes
1 answer
0 votes
1 answer

Geo-location microphone camera pop up

To Allow or Block the notification, access using Selenium and you have to ...READ MORE

answered May 11, 2018 in Selenium by Samarpit
• 5,130 points
628 views
0 votes
1 answer

How to use such xpath to find web elements

It's much simpler to use: #MyDiv123 > div.super or ...READ MORE

answered Jun 14, 2018 in Selenium by Samarpit
• 5,130 points
256 views
0 votes
1 answer

How to get next sibling element using XPath and Selenium for Java?

Below code will help you: Try following-sibling axis : WebElement ...READ MORE

answered May 15, 2018 in Selenium by Samarpit
• 5,130 points
4,645 views
0 votes
1 answer