We have Implemented loadWebBrowser() and closeWebBrowser() functions In PREVIOUS POST to centralize browser loading activity. Now supposing you wants to run your webdriver test In any other browser like Google Chrome then how will you do It? Our framework should have some facility to run selenium webdriver test In your desired browser. Let us do It.
Prerequisite : All previous selenium data driven framework creation steps should be Implemented. All previous steps link are given on THIS PAGE.
To run your selenium webdriver test In some other browser, We have to modify our loadWebBrowser() function. Also we have to create properties file In our project to store the browser name In which browser you wants to run your test. We will use It to store other properties too.
Download Required Files
You need total 4 files for this step.
- SuiteBase.java
- Param.properties
- chromedriver.exe
- IEDriverServer.exe
You can get latest version of "chromedriver.exe" file from THIS PAGE and "IEDriverServer.exe" from THIS PAGE too.
You need modified SuiteBase.java file, and need to add newly created Param.properties file to run your test on Chrome or Firefox or Internet Explorer browser. You will get both files by downloading bellow given zip folder.
So now you have all required 4 files. Copy paste them as described bellow.
- Paste SuiteBase.java file on com.stta.TestSuiteBase Package.
- Paste Param.properties file on com.stta.property Package.
- Create new folder with name = "BrowserDrivers" under your project and put "chromedriver.exe" and "IEDriverServer.exe" Inside It.
Now your directory structure will looks like bellow.
Now you can run your webdriver test on your required browser. Only you have to change testBrowser name In Param.properties file.
- Set testBrowser = Mozilla to run your test In Mozilla Firefox browser.
- Set testBrowser = Chrome to run your test In Google Chrome browser.
- Set testBrowser = IE to run your test In Internet Explorer browser.
Note : If you wants to run all your tests In single browser Instance then remove closeWebBrowser(); from @AfterTest method of all four test cases. Now your all tests will run In single browser Instance.
How to run WebDriver test on Mozilla Firefox Browser
- Open Param.properties file In eclipse and set testBrowser=Mozilla and save file.
- Double click on "Run Test.bat" file from desktop to run test suites.
Test suites will be executed In Mozilla Firefox browser.
How to run WebDriver test on Google Chrome Browser
- Open Param.properties file In eclipse and set testBrowser=Chrome and save file.
- Double click on "Run Test.bat" file from desktop to run test suites.
Test suites will be executed In Google Chrome browser.
How to run WebDriver test on Internet Explorer Browser
- Open Param.properties file In eclipse and set testBrowser=IE and save file.
- Double click on "Run Test.bat" file from desktop to run test suites.
Test suites will be executed In Internet Explorer browser.
So now you can manage your test browser from Param.properties file. You can set your required browser In Param.properties file then all your tests will run In that specific browser.
So now you can manage your test browser from Param.properties file. You can set your required browser In Param.properties file then all your tests will run In that specific browser.
I kept,
ReplyDeletetestBrowser=IE
testBrowser=Mozilla
testBrowser=Chrome , 3 browsers in param.properties but test cases are executing only in chrome browser
I Kept
ReplyDeletetestBrowser=ie in param.properties but test cases are excuting only in firefox...
Hi,
ReplyDeleteFor Me Test cases are not executed in any of the browser. Can you help me out