Q:

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

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);
0

New to Communities?

Join the community