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,320 points
3,861 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,910 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
• 28,140 points
44,045 views
0 votes
1 answer
0 votes
1 answer
+1 vote
1 answer
0 votes
2 answers

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,500 points
12,618 views
0 votes
2 answers

Problem while using InternetExplorerDriver in Selenium WebDriver

enable trusted connection  in internet explorer by ...READ MORE

answered Aug 31, 2020 in Selenium by Sri
• 3,190 points
8,572 views
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,910 points
6,629 views
0 votes
2 answers

How to use such xpath to find web elements

xpath are two types. 1) Absolute XPath:    /html/b ...READ MORE

answered Sep 3, 2020 in Selenium by Sri
• 3,190 points
7,519 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,910 points
20,280 views
0 votes
1 answer
webinar REGISTER FOR FREE WEBINAR X
REGISTER NOW
webinar_success Thank you for registering Join Edureka Meetup community for 100+ Free Webinars each month JOIN MEETUP GROUP