Introduction to IO streams /external files in Selenium
- For better maintenance of the project we are goiing to take the test data and locators by using the external files like excel text pad, xml ,database e.t.c
- We are going to use excel files to maintain the test data&locators.
- We can store the data in a format with the help of rows& columns. so the maintain is easy.
- If you save the excel .xls format [Excel 97-2003 workbook[xls]]
- Then it can access in any operating system[platform independence]
- As part of manual testing we are maintaining test cases & test data in Excel file .so we can directly access those files to take the test data.
- To support Excel files we need to configure jx1.jar file in Eclipse.
- We can download the jx1.jar file from our site selenium testing
- http://selenium in for testing
- Copy jx1.jar file in lib folder.
- Configure it in Eclipse by using same steps as sikuli jar file
- The data which we are going to use to test the application is known as test data.
- Create a folder with the name “test data” under the project folder of “work space”.
- Take an Excel file and give the test data in below format
User name (JanJo selenium)
- Save the Excel file with .xls formate [97-2003] in test data folder
* Write a program to login into mail .in.com by banking object repository from an excel file
repository mean a storage folder .object repository mean a storage folder which contains the element location like id, css, x path, name e.t.c.
Create a folder with the name of workspace.
Take an Excel file and give the object repository in below format.
User name (f_ id) pass word (f_ pwd) sign (input _ sign in)
Save the Excel file in .Xis format [97 -2003] in or Folder
Inclined to build a profession as Selenium Developer? Then here is the blog post on Selenium Training In Chennai.
* Write a program to test the log in functionality of mail income by the rest data and object repository from 2
Different Excel Files:
Public class log in _ OR
Public web driver driver;
Public FileinputStream fi;
Public Workbook w;
Public Sheet S;
Public void verify login ( ) thrown Exception
fi = new File inputStream (“E:\\…\\OR\\login.XIS”);
w = Workbook. Getworkbook(fi);
driver . Find Element (By.id(s.getclass(0,1). Get content())) . send keys(Jan 30 selenium)
driver.Find Element …(1,1) ….(“selenium”)
driver. Find element (By.cssSelection(s.getcell(2,1).get content()) .click();
@ Test public void verify logout()from exe
* Write a program to test the login functionality with multiple sets of login
* Write a program to test the login functionality of the gmail.com with multiple sets of login credentials
* Test the log in functionality of mail.in.com with multiple sets of login credentials and provide the results in the below formula
|Jan 30 selenium||selenium||Pass|
To accomplish the above scenario we need to fallow below 3 steps
- Create an Excel File [Result File]
- Add the complete i/p data to the created resuch file
- Add a result column and provide the resuch an pass or fail based on the execution
Create a folder with the name ”Result” under the project folder of “work space 10” and capture all the results into this folder
Public void step1() throws Exception
FileoutputStream fo = new FileOutputStream (“E:\\work Space _10Am \\ selenium\\ result\\login.XIS”);
Writable Work book wb = Workbook.createworkbook(fo);
Writetable Sheet ws = wb.create sheet (“Results” ,0);
Label un = new Label (0,0 “username”);
Label pw= new Label (1,0 “password”);
Label rs= new Label (2,0 “Result”);
- add cell(un);
- add cell(pw);
- add cell(rs);
Nested for loop syntax:
For (int i= 0; I<3; i++)
For (int j= 0; j<2; j++)
Step 2: program
Public class add input data to result File
Public void step 2() throws exception
//1. Print the i/p data on the console
- create result file and add provide console output
FileinputStream fi = new FileinputStream(“E:\\workspace_10AM\salenium\\Testdata….”)
Workbook w = workbook. Get workbook(fi);
Sheet S = w.get Sheet(0);
Fileoutput Stream fo = new file output Stream(“E:\\work space _10AM\selenium \\result”)
Create table workbook wb = workbook.create workbook(fo);
Writeable sheet us = wb. Create sheet(“Result”,0);
For(int i=0; i< l.getrow(); i++)
For(int j=0; i< l.getcolumn(); j++)
Label un = new Label (j,i, s. getcell(j.i).get content());
Cabel rs = new label (2,0,”result”);
Ws. Add cell(rs);
Check out the top Selenium Interview Questions now!
It is two types
1) implicit time:-it is standard time
2) explicit time:-it means wait until the elements is available
Public void wait(String str)
For(int i=0; i<20; i++)
If(selenium .in element process(str))
How we can use in program:
Public static void method()
iIf we are while loop then signout in not there then it keep out executing infinite times
X HOS Admin Admit
Y HOS Admin Advice Admit
Data driver frame work:-
Develop the driver script [data driver frame work] from the scenario login & registration of mail.in.com
to develop the driver script take the test data and object repository in an Excel file with below format
Public void reusable script() throws exception
Fileinput Stream fi = new fileinput Stream(“E:\\workspace_10AM \\selenium\\”)
Workspace w = workbook.getworkbook(fi);
Sheet s w.get sheet(“sheet1”);
For(int i= 1; i< s.get row(); i++)
If(s.getcell(2,i).get contents().Excelignore case(“textbox”))
If(selenium .inelement present(s.getcell(0,i).get content()))
Selenium .type(s.getcell(0,i).get content(), s.getcontent())
develop the test data and object repository in a excel file for spicejet.com and run the script by using driver script
àonce the exception is copltted provide the results in an Excel file[resilt file]
Step1:- create an Excel file by using file output stream
Step 2:-Add input data to the result file by using ‘j loop’[ nested for loop’]
Step3:-Add a result column and provide the result as pass or fail based or the execution.
- Explain about your frame work
- Main is hybrid frame work.
- It is a combination of test NG & data driver frame work.
- We can use both the advantage of data driver &test NG[key board driver]
- We are using xml file to execute both the test scripts[class].
Explain about your Framework?
Hybrid frame work
it is a combination if test NG an data driven frame work
we can use both the advantages of data driven and Test NG[Key word Driver]
we are using XML file to executes both the test script[class]
For an Indepth knowledge on Selenium, click on below