As you know, We have already Introduced Selenium webdriver In our test data driven framework during PREVIOUS POST. And now we are going ahead very slowly to use data driven framework In selenium webdriver tests.
Prerequisite : All previous data driven framework creation steps for selenium webdriver should be Implemented. You will get links for all steps at THIS PAGE.
If you have looked Inside all four test cases, All four test cases have a same code to open browser, to maximize browser and to set timeout. Right now, We have only 4 test cases In our framework but supposing you have 100 test cases In your real world project then you will repeat same code In all 100 test cases? This Is not good coding practice.. Right..? By centralizing load browser function, We will get bellow given 2 benefits.
Using centralized load browser, We can eliminate duplicate code In all test cases. So It will reduce code size.
In future, If you wants to change any thing In open browser function, You can do It easily from one place. Supposing you wants to change timeout from 15 seconds to 20 seconds then you have to modify code at only one place and It will be applied everywhere.
We will create one common function loadWebBrowser() In SuiteBase.java file and then will call It In all test cases.
loadWebBrowser() function will be useful to handle bellow given things.
To open the new browser Instance.
To apply Implicit wait for test.
In Next step, We will also Implement functionality to run your tests In other browsers like Google chrome and Internet Explorer and how to manage It from one place.
I have also Implemented closeWebBrowser() function and used It Inside @AfterTest method of all test cases to close browser after test case execution.
I have modified all test cases and SuiteBase.java files to Implement loadWebBrowser() and closeWebBrowser() functions. You will get all files by downloading bellow given zip folder.
Extract the folder and copy-paste all files on respective packages of "WDDF" project to replace existing files.
Double click on "Shortcut to Run Test.bat" file to run test. Observe test execution and results.