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,210 points
127 views

1 answer to this question.

Your answer

Your name to display (optional):
Privacy: Your email address will only be used for sending these notifications.
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 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
67 views
0 votes
1 answer

How to wait till the text is present In text field

Use Waits in Selenium WebDriver to wait ...READ MORE

answered Jul 5, 2018 in Selenium by Meci Matt
• 9,400 points
76 views
0 votes
1 answer

How to create a executable jar file for TestNG and the runnnig point should be the Xml file

Use Eclipse Export Wizard. While exporting, select "Create ...READ MORE

answered Aug 24, 2018 in Selenium by Meci Matt
• 9,400 points
804 views
0 votes
1 answer

How to wait for the webpage to load in selenium using java

Firstly, when you launch a web application, ...READ MORE

answered Aug 28, 2018 in Selenium by bug_seeker
• 14,960 points
84 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,030 points
51 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
412 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
40 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
3,678 views
0 votes
1 answer

© 2018 Brain4ce Education Solutions Pvt. Ltd. All rights Reserved.
"PMP®","PMI®", "PMI-ACP®" and "PMBOK®" are registered marks of the Project Management Institute, Inc. MongoDB®, Mongo and the leaf logo are the registered trademarks of MongoDB, Inc.