How to get the text from a website using selenium?

0 votes
I am using selenium. I want to scrape out the text from a website. How to do this using selenium?

Can someone help me with this.
Dec 31, 2018 in Selenium by Sradha
• 1,720 points
4,184 views

1 answer to this question.

0 votes

hey, you can use get.text() method to get the string from the particular section of the website. 

Here is the program that I used and it worked pretty well.

System.setProperty("webdriver.chrome.driver","C:\\Users\\priyj_kumar\\Downloads\\chromedriver.exe");
WebDriver driver = new ChromeDriver();
driver.get("https://en.wikipedia.org/wiki/Main_Page");
String str = driver.findElement(By.xpath("//*[@id='mp-tfa']/p")).getText();
System.out.println(str);

This way you can get the string from the website.

answered Dec 31, 2018 by Sudhanshu

Related Questions In Selenium

0 votes
0 answers
+1 vote
1 answer

How to get typed text from a textbox by using Selenium Webdriver?

Hey Ashmita, to get the typed text ...READ MORE

answered Jun 24, 2019 in Selenium by Abha
• 27,780 points
3,284 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
• 13,100 points
1,683 views
+1 vote
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
1,825 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,870 points
1,624 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,870 points
1,480 views
0 votes
1 answer

How to extract text from a web page using selenium and save it as a text file?

Hello Isha, you can checkout this code ...READ MORE

answered May 7, 2019 in Selenium by Anvi
• 14,010 points
8,809 views
0 votes
1 answer

How to get the text from all the cells of an HTML table?

This worked for me. Check this out import ...READ MORE

answered May 10, 2019 in Selenium by Surya
• 970 points
95 views