Reading Site URL From properties File In Selenium WebDriver DDF

In selenium WebDriver Datadriven Framework Creation, We have Implemented functionality of running test cases In different browsers In Previous Step. And for that, you have to change your test browser name at one place only. So now you can set your test browser In file. Now next step Is reading site URL from file.


Prerequisite : All previous 24 steps of Selenium WebDriver DDF creation should be Implemented. Find all steps link on THIS PAGE.

Why need to read site URL from properties file?
Supposing you have a test site with development and staging environment and you have created 100 different test case files for your project.

Assume -> Right now you are running your webdriver test cases on development environment site. But after few days you have to run all webdriver test cases on stage environment site. How will you do It? You will go for changing site URL In all 100 test cases? It will take too much time and It Is not perfect way.

To handle this kind of situation, We can store site URL In file and then we can use that URL's key In all our test cases. So whenever you wants to run your test cases on staging environment, you have to change site URL key value only In file. This Is one kind of URL centralization.

How to do It?
For that, We have to modify our all four test cases files. We will store our test site's URL In file with key siteURL and then we will access Its value In our all four test cases. Right now, Our all four test cases has bellow given syntax.

//To navigate to URL.

Now you need to replace above syntax. Remove above syntax and add bellow given syntax In all four test cases.

//To navigate to URL. It will read site URL from file

Now It will read siteURL key's value from file. You can download file and one modified test case for your example from bellow given link. 

Note : In zip folder, You will get only one modified test case. But you have to modify your all four test cases accordingly.

  • Paste file on com.stta.SuiteOne Package.
  • Paste file on Package.
Running test to verify result

Double click on Shortcut to Run Test.bat file to run your test cases. It will start executing your test cases. Now It will read URL from file In all four test cases. You can verify It by changing siteURL key's value in file.

No comments:

Post a Comment