package selenium_examples;
import java.io.FileNotFoundException;
import java.io.FileOutputStream;
import java.io.IOException;
import jxl.Workbook;
import jxl.write.WritableSheet;
import jxl.write.WritableWorkbook;
import jxl.write.Label;
import jxl.write.WriteException;
import jxl.write.biff.RowsExceededException;
import org.openqa.selenium.By;
import org.openqa.selenium.Keys;
import org.openqa.selenium.WebDriver;
import org.openqa.selenium.firefox.FirefoxDriver;
public class Sample {
public static void main(String[] args) throws IOException, RowsExceededException, WriteException {
WebDriver driver = new FirefoxDriver();
driver.get("http://www.funandknowledge.blogspot.com");
String s=driver.getTitle();
System.out.println(s);
FileOutputStream f = new FileOutputStream("E:\\Test.xls");
WritableWorkbook book = Workbook.createWorkbook(f);
WritableSheet sheet = book.createSheet("Output",1);
Label l = new Label(0,0,s);
sheet.addCell(l);
book.write();
book.close();
}
}
Output:-QTP Scripts and Selenium Webdriver Scripts
Above script writes the title of website "http://www.funandknowledge.blogspot.com" to the excel sheet.
import java.io.FileNotFoundException;
import java.io.FileOutputStream;
import java.io.IOException;
import jxl.Workbook;
import jxl.write.WritableSheet;
import jxl.write.WritableWorkbook;
import jxl.write.Label;
import jxl.write.WriteException;
import jxl.write.biff.RowsExceededException;
import org.openqa.selenium.By;
import org.openqa.selenium.Keys;
import org.openqa.selenium.WebDriver;
import org.openqa.selenium.firefox.FirefoxDriver;
public class Sample {
public static void main(String[] args) throws IOException, RowsExceededException, WriteException {
WebDriver driver = new FirefoxDriver();
driver.get("http://www.funandknowledge.blogspot.com");
String s=driver.getTitle();
System.out.println(s);
FileOutputStream f = new FileOutputStream("E:\\Test.xls");
WritableWorkbook book = Workbook.createWorkbook(f);
WritableSheet sheet = book.createSheet("Output",1);
Label l = new Label(0,0,s);
sheet.addCell(l);
book.write();
book.close();
}
}
Output:-QTP Scripts and Selenium Webdriver Scripts
Above script writes the title of website "http://www.funandknowledge.blogspot.com" to the excel sheet.
No comments:
Post a Comment