Session 9: Data Driven Framework with XML
Objectives
- Types of Framework
- Building Data Driven Framework with XML
- Dynamic Web-Table
- Test Case: Add Contact
Project URL: https://github.com/remotecontainer/DataDrivenProjectWithXML.git
12/14/2019
https://bitbucket.org/codestack1/datadrivenframeworkwithxml.git
Notes:
What type of framework do you use?
> Hybrid framework
> Project is configured with Maven
> Dependencies that keep the project jar files current
> Folders and packages use the Page Object Model
> Page package hold page classes where elements and
methods to interact with the page resides
> Test Package
> Util> BrowserFactory: What does it do?
> PageFactory: is used to link classes with the driver,
> BasePage:
> ChromeDriver
> Data Folder
> TestNG to run tests and generate report
>Console report along with an emailable html report,
> Apache poi dependencies are used to integrate excel files,
> Hybrid framework
> Project is configured with Maven
> Dependencies that keep the project jar files current
> Folders and packages use the Page Object Model
> Page package hold page classes where elements and
methods to interact with the page resides
> Test Package
> Util> BrowserFactory: What does it do?
> PageFactory: is used to link classes with the driver,
> BasePage:
> ChromeDriver
> Data Folder
> TestNG to run tests and generate report
>Console report along with an emailable html report,
> Apache poi dependencies are used to integrate excel files,
PowerPoint Notes
automation_framework.pptx |
Steps to build a Data Driven Framework using xml
1. Build a TestNG Maven Project (As instructed earlier with only Selenium-Java and TestNG dependency),
2. Add BrowserFactory and a test class to make sure the Driver works,
3. Create a test case method and add the following above the method:
@Test
@Parameters({"variable", "example", "phone", "address", "city", "state"})
4. Import TestNG and Parameters annotation,
5. Add equal number of parameters to the above test method as below:
public void addContact(String variable, String example, String phone, String address, String city, String state)
6. Use these parameters as needed within the test case,
7. Add xml file,
a. Create a folder called Data in the project,
b. Right Click on the folder > Click New > Other ,
c. Find and select XML file > Click Next,
d. Type a file name including ".xml",
e. Click Finish,
6. Copy Paste the following in the xml file and modify the values in the quotations accordingly:
<suite name="regression"> //Name of the test suite
<test name="AddContactTest"> //Name of the test case
<parameter name="company" value="IBM" /> //Values to be passed
<parameter name="email" value="[email protected]" />
<classes>
<class name="test.AddContactTest" /> // Class name to inject the values into
</classes>
</test>
</suite>
8. Right click on the xml file > Click Run As > Click TestNG Suite.
2. Add BrowserFactory and a test class to make sure the Driver works,
3. Create a test case method and add the following above the method:
@Test
@Parameters({"variable", "example", "phone", "address", "city", "state"})
4. Import TestNG and Parameters annotation,
5. Add equal number of parameters to the above test method as below:
public void addContact(String variable, String example, String phone, String address, String city, String state)
6. Use these parameters as needed within the test case,
7. Add xml file,
a. Create a folder called Data in the project,
b. Right Click on the folder > Click New > Other ,
c. Find and select XML file > Click Next,
d. Type a file name including ".xml",
e. Click Finish,
6. Copy Paste the following in the xml file and modify the values in the quotations accordingly:
<suite name="regression"> //Name of the test suite
<test name="AddContactTest"> //Name of the test case
<parameter name="company" value="IBM" /> //Values to be passed
<parameter name="email" value="[email protected]" />
<classes>
<class name="test.AddContactTest" /> // Class name to inject the values into
</classes>
</test>
</suite>
8. Right click on the xml file > Click Run As > Click TestNG Suite.
Homework
Automate the following scenario and push the code to create a pull request.
1. Login to TechFios
2. Navigate to Bank & Cash > New Account (Hint: Create navigation method in Dashboard Class)
3. Enter new account information (Hint: Create method in the Add Accounts Page class)
4. Verify success message appeared (Hint: Create method in the Add Accounts Page class)
5. Verify name appeared in the table (Hint: Dynamic Web-Table)
Detailed Instruction:
Level 1:
> Create two classes: NewAccountPage and NewAccountTest
> Create A test method in NewAccountTest class with TestNG annotation
Level 2:
> Copy paste existing methods to login and verify user logged in.
Level 3:
> Create Navigation Method in the Dashboard Page to navigate to New Account Page,
Level 4:
> Create addNewAccount method in the NewAccountPage class
Level 5:
> Write assertion to validate success message
Level 6:
> Write Assertion to validate table contains the newly added data.
OR
Level 7:
> Write Assertion to validate table contains the newly added data using dynamic web-table.
!!Congratulation!! You are an expert now!!
Class Notes
XML - Extensible Markup Language
HTML - HyperText Markup Language
XML
- Designed to encapsulate and carry data
- Must have a software to utilize the data
- Platform/operating system independent
- Does not have predefined tags, only <></>
- Human and machine readable
HTML
- Designed to display the data
- Must use Predefined tags
- <p></p>
- <button></>
- <br></br>
Types of Testing
1. Smoke/Sanity
- Overall or Macro
- Fast testing
2. Regression
Two way to run automation:
1. In my local (Not regression run)
2. Run on Jenkins (smoke and regression suite)
Class Activity: (20 min)
1. Get in groups,
2. Look through techfios site,
3. Formulate a unique test case.
Example:
Test Case: User should be able to view account statements
1. Login
2. Navigate to Account Statements page,
3. Select an account
4. Select a from date
5. Select to date,
6. Select type,
7. Click on View Statements
8. PDF File link should display.
Test Case: Create a new invoice
1. Loing,
2. Navigate to New Invoice Page,
3. Enter a random Item Name,
4. Enter Qty
5. Enter price
6. Select a customer
7. Click save and close,
8. Validate new invoice data appeared
HTML - HyperText Markup Language
XML
- Designed to encapsulate and carry data
- Must have a software to utilize the data
- Platform/operating system independent
- Does not have predefined tags, only <></>
- Human and machine readable
HTML
- Designed to display the data
- Must use Predefined tags
- <p></p>
- <button></>
- <br></br>
Types of Testing
1. Smoke/Sanity
- Overall or Macro
- Fast testing
2. Regression
Two way to run automation:
1. In my local (Not regression run)
2. Run on Jenkins (smoke and regression suite)
Class Activity: (20 min)
1. Get in groups,
2. Look through techfios site,
3. Formulate a unique test case.
Example:
Test Case: User should be able to view account statements
1. Login
2. Navigate to Account Statements page,
3. Select an account
4. Select a from date
5. Select to date,
6. Select type,
7. Click on View Statements
8. PDF File link should display.
Test Case: Create a new invoice
1. Loing,
2. Navigate to New Invoice Page,
3. Enter a random Item Name,
4. Enter Qty
5. Enter price
6. Select a customer
7. Click save and close,
8. Validate new invoice data appeared
Tricks
“Ctrl + Shift + F + O” - Alight and remove unused imports.
“Ctrl + Alt + Down" - Duplicate the row where is the cursor is.
"Alt + Left" - Navigate back.
"Alt + Right" - Navigate forward.
“Ctrl + Alt + Down" - Duplicate the row where is the cursor is.
"Alt + Left" - Navigate back.
"Alt + Right" - Navigate forward.