How to use xpath to get a specific text from a website?

+1 vote
Hello, I am new to selenium and am learning about Xpath, how can I use Xpath to locate a text in any website?
Dec 19, 2018 in Selenium by Jino
• 5,560 points
95 views

1 answer to this question.

0 votes

The task is to get the text using XPATH. XPath is a locator used to locate an element using the XML path. XPath stores the key-value pair similar to HTML tags.

So, inorder to find the Text all you need to do is:

driver.findElement(By.xpath("//*[contains(text(),'the text you are searching for')]"));

This way you can find the text you are looking for.

Hope this helps @Jino

answered Dec 19, 2018 by Nabarupa

Related Questions In Selenium

0 votes
1 answer

How to get the text from a website using selenium?

hey, you can use get.text() method to ...READ MORE

answered Dec 31, 2018 in Selenium by Sudhanshu
1,419 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,090 points
769 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
1,012 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
719 views
+1 vote
2 answers

How to get the title of a webpage using Selenium Java?

Essentially, driver.getTitle(); function can be used to ...READ MORE

answered Dec 17, 2018 in Selenium by Vardhan
• 12,570 points
387 views
0 votes
1 answer

How to use link as a locator to find element in selenium?

Hello @Jino, its amazing to explore ways ...READ MORE

answered Dec 21, 2018 in Selenium by Nabarupa
98 views