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,330 points
1,050 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,890 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, 2019 in Selenium by Abha
• 27,930 points
10,758 views
0 votes
1 answer
0 votes
1 answer
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,510 points
3,101 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,890 points
2,346 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,890 points
2,497 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,890 points
11,119 views
0 votes
1 answer