Introduction to IO streams /external files in Selenium
- For better maintenance of the project we are going 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 maintenance 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 the 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 the lib folder.
- Configure it in Eclipse by using the 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 “workspace”.
- Take an Excel file and give the test data in the below format
User name (JanJo selenium)
- Save the Excel file with .xls formate [97-2003] in the 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
* 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;
Public FileinputStream fi;
Public Workbook w;
Public Sheet S;
Public void verify login ( ) thrown Exception
fi = new File inputStream (“E:...ORlogin.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 login the 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 follow below 3 steps
- Create an Excel File [Result File]
- Add the complete i/p data to the created such file
- Add a result column and provide the research a pass or fail based on the execution
Create a folder with the name ”Result” under the project folder of “workspace 10” and capture all the results into this folder
Public void step1() throws Exception
FileoutputStream fo = new FileOutputStream (“E:work Space _10Am selenium resultlogin.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 an exception
//1. Print the i/p data on the console
- create result file and add provide console output
FileinputStream fi = new FileinputStream(“E:workspace_10AMsaleniumTestdata….”)
Workbook w = workbook. Get workbook(fi);
Sheet S = w.get Sheet(0);
Fileoutput Stream fo = new file output Stream(“E:work space _10AMselenium 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 the standard time
2) explicit time:-it means wait until the elements are available
Public void wait(String str)
For(int i=0; i<20; i++)
If(selenium .in element process(str))
How we can use in the program:
Public static void method()
iIf we are while loop then sign out in not there then it keeps out executing infinite times
X HOS Admin Admit
Y HOS Admin Advice Admit
Interested to become master in Selenium? Enroll now for FREE demo on Selenium Training in New York City.
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 an 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 an excel file for spicejet.com and run the script by using driver script
àonce the exception is completed provide the results in an Excel file[resilt file]
Step1:- create an Excel file by using the 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 framework
- The Main is a hybrid framework.
- It is a combination of test NG & data driver framework.
- 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 your Framework?
it is a combination if test NG a data-driven framework
we can use both the advantages of data-driven and Test NG[Key word Driver]
we are using an XML file to executes both the test script[class]
For an In-depth knowledge on Selenium, click on below
- Selenium Grid
- Conditional statements in Selenium
- Different flavors of Selenium
- Selenium WebDriver Features