Show / Hide Table of Contents

Class SeleniumDriver

Driver class for Selenium WebDriver.

Inheritance
System.Object
SeleniumDriver
Implements
ITestingDriver
Inherited Members
System.Object.Equals(System.Object)
System.Object.Equals(System.Object, System.Object)
System.Object.GetHashCode()
System.Object.GetType()
System.Object.MemberwiseClone()
System.Object.ReferenceEquals(System.Object, System.Object)
System.Object.ToString()
Namespace: TestingDriver
Assembly: TestingDriver.dll
Syntax
public class SeleniumDriver : ITestingDriver

Constructors

| Improve this Doc View Source

SeleniumDriver(String, Int32, String, String, String, Int32, String, String, String, Boolean, Boolean, IWebDriver, String, Int32)

Initializes a new instance of the SeleniumDriver class.

Declaration
public SeleniumDriver(string browser = "chrome", int timeOut = 5, string environment = "", string url = "", string screenshotSaveLocation = "./", int actualTimeout = 60, string loadingSpinner = "", string errorContainer = "", string remoteHost = "", bool headless = true, bool incogMode = true, IWebDriver webDriver = null, string browserSize = "max", int localTimeout = 30)
Parameters
Type Name Description
System.String browser

The browser to use.

System.Int32 timeOut

The time out in seconds.

System.String environment

The environment of the test.

System.String url

Default url to naivgate to.

System.String screenshotSaveLocation

Location to save screenshots.

System.Int32 actualTimeout

Time out limit in minutes.

System.String loadingSpinner

The xpath for any loading spinners.

System.String errorContainer

The xpath for any error containers.

System.String remoteHost

The address of the remote host.

System.Boolean headless

Indicate whether to run the browser in headless mode.

System.Boolean incogMode

Indicate whether to run the browser in incognito mode.

OpenQA.Selenium.IWebDriver webDriver

Any Web driver to be passed in.

System.String browserSize

The execution type which indicates how the test will be executed in.

System.Int32 localTimeout

The timeout indicating how long to wait to find individual elements.

Properties

| Improve this Doc View Source

CurrentURL

Gets the url of the page the webdriver is focued on.

Declaration
public string CurrentURL { get; }
Property Value
Type Description
System.String
| Improve this Doc View Source

ErrorContainer

Gets or sets the error container to check if any errors are shown on the UI.

Declaration
public string ErrorContainer { get; set; }
Property Value
Type Description
System.String
| Improve this Doc View Source

LoadingSpinner

Gets or sets the loadiong spinner that appears on the website.

Declaration
public string LoadingSpinner { get; set; }
Property Value
Type Description
System.String
| Improve this Doc View Source

LocalTimeout

Gets or sets the local timeout to attempt to find and wait for elements.

Declaration
public int LocalTimeout { get; set; }
Property Value
Type Description
System.Int32
| Improve this Doc View Source

Name

Gets the name of the testing driver.

Declaration
public ITestingDriver.TestingDriverType Name { get; }
Property Value
Type Description
ITestingDriver.TestingDriverType
| Improve this Doc View Source

WebDriver

Gets the web driver in use.

Declaration
public IWebDriver WebDriver { get; }
Property Value
Type Description
OpenQA.Selenium.IWebDriver

Methods

| Improve this Doc View Source

AcceptAlert()

Accepts the alert provided that there is an alert.

Declaration
public void AcceptAlert()
| Improve this Doc View Source

Back()

Goes back a page.

Declaration
public void Back()
| Improve this Doc View Source

Check(String, Boolean, String)

Sets the check box's value to ON.

Declaration
public void Check(string xPath, bool byJS = false, string jsCommand = "")
Parameters
Type Name Description
System.String xPath

The xpath to find the specified element.

System.Boolean byJS

Whether to use JS to perform the click / not.

System.String jsCommand

Any js command needed.

| Improve this Doc View Source

CheckErrorContainer()

Checks if there are any errors in the error container.

Declaration
public void CheckErrorContainer()
| Improve this Doc View Source

CheckForElementState(String, ITestingDriver.ElementState, String)

Checks for an element state.

Declaration
public bool CheckForElementState(string xPath, ITestingDriver.ElementState state, string jsCommand = "")
Parameters
Type Name Description
System.String xPath

The xpath to find the web element.

ITestingDriver.ElementState state

The state of the web element to wait for.

System.String jsCommand

Any JS command to use when finding the element.

Returns
Type Description
System.Boolean

If the element state is as wanted.

| Improve this Doc View Source

ClickElement(String, Boolean, String)

Performs the actions of clicking the specified element. Uses Selenium binding by default.

Declaration
public void ClickElement(string xPath, bool byJS = false, string jsCommand = "")
Parameters
Type Name Description
System.String xPath

The xpath to find the specified element.

System.Boolean byJS

Whether to use JS to perform the click / not.

System.String jsCommand

Any js command needed.

| Improve this Doc View Source

CloseBrowser(Boolean)

Closes the current window. It will quit the browser if it is the last window opened.

Declaration
public void CloseBrowser(bool closeAll)
Parameters
Type Name Description
System.Boolean closeAll
| Improve this Doc View Source

DismissAlert()

Dismisses the alert provided taht there is an alert.

Declaration
public void DismissAlert()
| Improve this Doc View Source

ExecuteJS(String)

Executes JS command.

Declaration
public void ExecuteJS(string jsCommand)
Parameters
Type Name Description
System.String jsCommand

command.

| Improve this Doc View Source

ForceKillWebDriver()

Force kill web driver.

Declaration
public void ForceKillWebDriver()
| Improve this Doc View Source

Forward()

Goes Fowards a page.

Declaration
public void Forward()
| Improve this Doc View Source

GenerateAODAResults(String)

Generates the AODA results.

Declaration
public void GenerateAODAResults(string folderLocation)
Parameters
Type Name Description
System.String folderLocation

The folder to generate AODA results in.

| Improve this Doc View Source

GetAlertText()

Gets the text inside the alert.

Declaration
public string GetAlertText()
Returns
Type Description
System.String

Alert Text.

| Improve this Doc View Source

GetAllLinksURL()

The GetAllLinksURL.

Declaration
public List<string> GetAllLinksURL()
Returns
Type Description
System.Collections.Generic.List<System.String>

The List{string}.

| Improve this Doc View Source

GetElementAttribute(String, String, String)

Returns the given attribute for the element given.

Declaration
public string GetElementAttribute(string attribute, string xPath, string jsCommand = "")
Parameters
Type Name Description
System.String attribute
System.String xPath

xpath to find the attribute.

System.String jsCommand

any js command to use.

Returns
Type Description
System.String

the value of the attribute.

| Improve this Doc View Source

GetElementText(String, String)

Returns the given text for the element given.

Declaration
public string GetElementText(string xPath, string jsCommand = "")
Parameters
Type Name Description
System.String xPath

xpath to find the attribute.

System.String jsCommand

any js command to use.

Returns
Type Description
System.String

the value of the attribute.

| Improve this Doc View Source

GetWebElement(String, String)

Returns the webElement at the given xPath.

Declaration
public IWebElement GetWebElement(string xPath, string jsCommand = "")
Parameters
Type Name Description
System.String xPath

The xpath to find the element at.

System.String jsCommand

any Js Command To use.

Returns
Type Description
OpenQA.Selenium.IWebElement

The web element.

| Improve this Doc View Source

LaunchNewTab(String, Boolean)

Tells the browser to launch a new tab.

Declaration
public bool LaunchNewTab(string url = "", bool instantiateNewDriver = false)
Parameters
Type Name Description
System.String url

URL for the browser to navigate to.

System.Boolean instantiateNewDriver

Instantiates a new selenium driver.

Returns
Type Description
System.Boolean
true
if the navigation was successful.
| Improve this Doc View Source

Maximize()

Maximizes the browser.

Declaration
public void Maximize()
| Improve this Doc View Source

NavigateToURL(String, Boolean)

Tells the browser to navigate to the provided url.

Declaration
public bool NavigateToURL(string url = "", bool instantiateNewDriver = true)
Parameters
Type Name Description
System.String url

URL for the browser to navigate to.

System.Boolean instantiateNewDriver

Instantiates a new selenium driver.

Returns
Type Description
System.Boolean
true
if the navigation was successful.
| Improve this Doc View Source

PopulateElement(String, String, String)

Performs the action of populating a value.

Declaration
public void PopulateElement(string xPath, string value, string jsCommand = "")
Parameters
Type Name Description
System.String xPath

The xpath to use to identify the element.

System.String value

The value to populate.

System.String jsCommand

Any js command needed.

| Improve this Doc View Source

Quit()

Quits the webdriver. Call this when you want the driver to be closed.

Declaration
public void Quit()
| Improve this Doc View Source

RefreshWebPage()

Refreshes the webpage.

Declaration
public void RefreshWebPage()
| Improve this Doc View Source

RunAODA(String)

Method to run aoda on the current web page.

Declaration
public void RunAODA(string providedPageTitle)
Parameters
Type Name Description
System.String providedPageTitle

Title of the web page the user provides.

| Improve this Doc View Source

SelectValueInElement(String, String, String)

Performs the action of selecting a value in an element.

Declaration
public void SelectValueInElement(string xPath, string value, string jsCommand)
Parameters
Type Name Description
System.String xPath

The xpath to use to identify the element.

System.String value

The value to select in the element.

System.String jsCommand

Any js command needed.

| Improve this Doc View Source

SendKeys(String)

The SendKeys.

Declaration
public void SendKeys(string keystroke)
Parameters
Type Name Description
System.String keystroke

The keystrokeSystem.String.

| Improve this Doc View Source

SetTimeOutThreshold(String)

Sets the global timeout in seconds.

Declaration
public void SetTimeOutThreshold(string seconds)
Parameters
Type Name Description
System.String seconds

maximum duration of timeout.

| Improve this Doc View Source

SwitchToIFrame(String, String)

Switches to appropriate IFrame. Use root in xpath to leave the iframe.

Declaration
public void SwitchToIFrame(string xPath, string jsCommand)
Parameters
Type Name Description
System.String xPath

xPath to find the iFrame. use "root" to leave iframe.

System.String jsCommand

Any js command needed.

| Improve this Doc View Source

SwitchToTab(Int32)

The SwitchToTab.

Declaration
public void SwitchToTab(int tab)
Parameters
Type Name Description
System.Int32 tab

The tabSystem.Int32.

| Improve this Doc View Source

TakeEntireScreenshot(String, Boolean)

Takes a screenshot of the browser. Screenshot will have the datestamp as its name. Year Month Date Hour Minutes Seconds (AM/PM).

Declaration
public bool TakeEntireScreenshot(string fileName, bool isMobile = false)
Parameters
Type Name Description
System.String fileName

The fileName of the testing driver.

System.Boolean isMobile

Whether it is a mobile device.

Returns
Type Description
System.Boolean
true
if screenshot was successfully taken.
| Improve this Doc View Source

TakeScreenShot(String)

Takes a screenshot of the browser. Screenshot will have the datestamp as its name. Year Month Date Hour Minutes Seconds (AM/PM).

Declaration
public void TakeScreenShot(string fileName)
Parameters
Type Name Description
System.String fileName

The fileName of the testing driver.

| Improve this Doc View Source

Uncheck(String, Boolean, String)

Sets the check box's value to OFF.

Declaration
public void Uncheck(string xPath, bool byJS = false, string jsCommand = "")
Parameters
Type Name Description
System.String xPath

The xpath to find the specified element.

System.Boolean byJS

Whether to use JS to perform the click / not.

System.String jsCommand

Any js command needed.

| Improve this Doc View Source

VerifyAttribute(String, String, String, String)

Returns whether or not the actual attribute value of the check box matches with the expected value, given a verification attribute string to check.

Declaration
public bool VerifyAttribute(string attribute, string expectedValue, string xPath, string jsCommand = "")
Parameters
Type Name Description
System.String attribute

Verification attribute string to check.

System.String expectedValue

Expected value to compare with.

System.String xPath

The xpath of the element.

System.String jsCommand

Any js command needed.

Returns
Type Description
System.Boolean
true
if actual attribute value matches with the expected value.
| Improve this Doc View Source

VerifyDropDownContent(List<String>, String, String)

Returns whether or not the drop down list contains all the given strings.

Declaration
public bool VerifyDropDownContent(List<string> expected, string xPath, string jsCommand = "")
Parameters
Type Name Description
System.Collections.Generic.List<System.String> expected

The list of expected strings.

System.String xPath

The xpath of the element.

System.String jsCommand

Any js command needed.

Returns
Type Description
System.Boolean
true
the drop down contains all the given strings.
| Improve this Doc View Source

VerifyElementSelected(String, String)

Returns whether or not the element is selected or not.

Declaration
public bool VerifyElementSelected(string xPath, string jsCommand = "")
Parameters
Type Name Description
System.String xPath

The xpath of the element.

System.String jsCommand

Any js command needed.

Returns
Type Description
System.Boolean
true
the element is current selected.
| Improve this Doc View Source

VerifyElementText(String, String, String)

Returns whether or not the element's text is the same as the expected value.

Declaration
public bool VerifyElementText(string expected, string xPath, string jsCommand = "")
Parameters
Type Name Description
System.String expected

What the value is expected to be.

System.String xPath

The xpath of the element.

System.String jsCommand

Any js command needed.

Returns
Type Description
System.Boolean
true
if it is the same.
| Improve this Doc View Source

VerifyFieldValue(String, String, String)

Returns whether or not the element's value attribute is the same as the expected value. Usually for form-like elements.

Declaration
public bool VerifyFieldValue(string expected, string xPath, string jsCommand = "")
Parameters
Type Name Description
System.String expected

What the value is expected to be.

System.String xPath

The xpath of the element.

System.String jsCommand

Any js command needed.

Returns
Type Description
System.Boolean
true
if it is the same.
| Improve this Doc View Source

Wait(Int32)

Sets implicit wait timeout in seconds.

Declaration
public void Wait(int seconds)
Parameters
Type Name Description
System.Int32 seconds

Maximum timeout duration in seconds.

| Improve this Doc View Source

WaitForElementState(String, ITestingDriver.ElementState, String)

Waits for an element state.

Declaration
public void WaitForElementState(string xPath, ITestingDriver.ElementState state, string jsCommand = "")
Parameters
Type Name Description
System.String xPath

The xpath to find the web element.

ITestingDriver.ElementState state

The state of the web element to wait for.

System.String jsCommand

Any js command needed.

| Improve this Doc View Source

WaitForLoadingSpinner()

Waits until the loading spinner disappears.

Declaration
public void WaitForLoadingSpinner()

Implements

ITestingDriver
  • Improve this Doc
  • View Source
In This Article
Back to top Generated by DocFX