Continuing from where we left of in part 3 – Feel free to use this link to browse it (Designing an automation framework – Part 3 – LearnXYZ) in case you missed out.
We need to install the required npm and other packages for our project.
Packages Required
Below is the list of packages that are pre-required in-order to make visual studio project work right out of the box.
1] Excel Data Reader — For Reading Excel Data
2] NUnit
3]NUnit Test Adapter
4] Selenium Support package
5] Selenium Web Driver
6] Selenium Web Driver Chrome Driver 2.27.0
7] Sharp Zip Library
8] Web Driver Chrome Driver — Has the driver that is copied in bin\debug or bin\release folder
NOTEThe packages specified below must be used for this framework and other projects that you want to create from this framework. The versions should be an exact match otherwise the project will give errs. |
Handling drivers for different browsers
Selenium supports many different browers for testing purposes.
Browser drivers are saved in the following location
Different browser drivers are kept in the below location.
Handling drivers for different browsers
Selenium supports many different browsers for testing purposes.
Browser drivers are saved in the following location
Different browser drivers are kept in the below location.
Chrome Driver
Every time we run the project the chrome driver is copied from below location to
D:\MAGICBLOCKS\GIT\OBQA\Automation\Jkrux.TestAutomation\packages\Selenium.WebDriver.ChromeDriver.2.27.0\driver OR
D:\MAGICBLOCKS\GIT\OBQA\Automation\Jkrux.TestAutomation\packages\WebDriverChromeDriver.2.10\tools\
This driver file if not replaced with the latest version (according to your browser version) will be copied from here to the respective time of run you are doing for the project — For Example Debug or Release.
Note: If the selenium drivers do not match the browser version then they would not run properly. |
D:\MAGICBLOCKS\GIT\OBQA\Automation\Jkrux.TestAutomation\Jkrux.TestAutomation.Tests\bin\Release
D:\MAGICBLOCKS\GIT\OBQA\Automation\Jkrux.TestAutomation\Jkrux.TestAutomation.Tests\bin\Debug
If the driver is old it will try to copy it here . Sometimes you get an error like below. This occurs because the driver (chromedriver.exe) is not automatically terminated and so it stays in used process and we cannot delete it.
Good To Go!
So once everything is in place we are ready to proceed with automation. Just open your automation project in Visual Studio Community Edition and start writing test cases and pages
We have implemented the program flow to utilize Page Object Model. So we have to create
- Pages
- Tests
Pages
Page holds UI and Elements related code. It can also hold calculations and other common methods that are to be implemented for Tests . The pages are always saved in the Pages folder – A directory structure similar to below Pages >> Main Module >> Sub Module >> Pages1,2,3.. and so on.
Sample Account Group List Page
This page is basically obtained by inheriting the BasePage.cs . All pages must start in the similar fashion. A page could have UI elements for a single feature or UI elements for the entire module. Although we encourage usage of the latter (Entire Module) as it will eliminate the need for redundancy or duplicate code issue. Also, if there is a change required for an element (Say a list) it can be done at one place and would reflect it in multiple Tests using the code. So it will also save time.
The modified syntax of writing the tests is that we would utilize one single file and add multiple tests to it with different attributes. Although we could create multiple files one for each test as well. BasePage has methods for Common UI methods and other methods which are required to be used in the tests.
In the next part we actually write the code