This project is a simple framework for creating Selenium tests using the Selenium WebDriver and the Selenium Grid. This version is using version 3 of the Selenium WebDriver.
Use this class to initialize an instance of the WebDriver, either local or remote. Current browsers supported are:
There are several overloadeds for the Initialize method:
- string browser
- string browser, string driverPath
- string browser, bool remote, string driverPath, Uri seleniumHubURL, string operatingSystem, , bool maximize
- string browser, Uri seleniumHubURL
- string browser, Uri seleniumHubURL, string operatingSystem, bool maximize
operatingSystem defaults to Any
maximize (the browser window) defaults to true for local execution and false for remote execution
InitializeRemote: Browser browser, Uri seleniumHubURL, string operatingSystem
You can use this method to initialize the remote webdriver directly.
You can set the remote webdriver URL in the app.config:
<appSettings>
<add key="SeleniumHubURL" value="http://127.0.0.1:4444/wd/hub" />
</appSettings>
This class contains useful methods to make tests easier to create.
GoTo: navigates to the desired URL
InputValue: sets the value of an Input textbox
SetDropDownItem: sets an option list to a specified option
WaitForElementReady: returns an iWebElement once it is available
on the web page
WaitForElementByIdReady: returns an iWebElement based on the document Id once it is available
on the web page
WaitForElementXpathIdReady: returns an iWebElement based on an Xpath selector once it is available
on the web page
GetDriver: returns an instance of the driver that is associated
with an iWebElement
GetID: returns the document Id of an iWebElement if it exists
GetClasses: returns a list of CSS classes for an iWebElement
HasClass: returns a bool if a class is present on an iWebElement
SetAttribue: sets the value of an HTML element's attribute
ExtractManifestResourceToDisk: supports extracting embedded resources allowing them
to be utilized for tests
ResetDriver: quit the driver and release any resources
CaptureScreenshot: captures the screen of a browser running on a remote node and saves it
to a text file in Base64 format
The project includes unit tests for the classes listed above as well as sample tests using the framework. Unit tests have categories so that you can segregate them if needed. For tests that have a category of RemoteWebDriver you must have a selenium grid running and the app.config with appSettings to provide the URL and location of where to store a screenshot if you with to capture them. Below is an example:
<appSettings>
<add key="SeleniumHubURL" value="http://127.0.0.1:4444/wd/hub" />
<add key="CaptureScreenshot" value="true"/>
<add key="ScreenShotPath" value="C:\\Temp\\screenshot"/>
</appSettings>