Writing data to text file using selenium webdriver

package selenium_examples;
import java.io.BufferedWriter;
import java.io.FileWriter;
import java.io.IOException;

public class Test{
 public static void main(String[] args) throws IOException {
 
   
   BufferedWriter bw = new BufferedWriter(new FileWriter("E:\\test.txt"));
   bw.write("Helloooo");
   bw.newLine();
                 bw.write("This is a new line");
                 bw.newLine();
                 bw.write("One more new line");
                 bw.close();
                 System.out.println("Done!");
 
   }
 }

Script 2:-

package selenium_examples;
import java.io.BufferedWriter;
import java.io.FileWriter;
import java.io.IOException;
import org.openqa.selenium.WebDriver;
import org.openqa.selenium.firefox.FirefoxDriver;

public class Test {
 public static void main(String[] args) throws IOException {
 
  WebDriver driver = new FirefoxDriver();
         driver.get("https://www.google.com");
         String s=driver.getTitle();
    
  BufferedWriter bw = new BufferedWriter(new FileWriter("E:\\test1.txt"));
  bw.write(s);
         bw.close();
                System.out.println("Done!");
 
   }
 }

 

2 comments:

Unknown said...

How to write multiple data in a doc file using selenium webdriver
also suggest me to how to use .docx file for the same

Unknown said...

how to write multiple data in doc file using selenium webdriver

also suggest me to use .docx for the same purpose

Related Posts Plugin for WordPress, Blogger...

Fun and Knowledge