Class ElementDescription
Describes how to identify an test object by its attributes, like Id, Name, XPath and any conbinations of them. WebEngine Framework can localize test object with multiple attributes. For web application testing, use the derived class WebElementDescription
Namespace: AxaFrance.WebEngine.Web
Assembly: AxaFrance.WebEngine.Web.dll
Syntax
public abstract class ElementDescription
Fields
| Improve this Doc View Sourcedriver
WebDriver used to identify test objects.
Declaration
protected WebDriver driver
Field Value
Type | Description |
---|---|
OpenQA.Selenium.WebDriver |
Properties
| Improve this Doc View SourceIsDisplayed
Check if The WebElement is displayed on the screen (In the current viewport or not)
Declaration
public bool IsDisplayed { get; }
Property Value
Type | Description |
---|---|
System.Boolean | True if the element exists and is displayed. False if the element exsits but not displayed. OpenQA.Selenium.NoSuchElementException if the element can't be find in the DOM. |
Remarks
If it is required to perform actions on non-displayed element, please bring the element into view before the action, using ScrollIntoView method.
IsEnabled
Get the value indicating whether the current element is enabled.
Declaration
public bool IsEnabled { get; }
Property Value
Type | Description |
---|---|
System.Boolean | True if the element is enabled, otherwise: False |
IsSelected
Check if the WebElement is selected. Applies only on checkboxes, options in a select element and radio buttons
Declaration
public bool IsSelected { get; }
Property Value
Type | Description |
---|---|
System.Boolean | True is the element is selected, otherwise, false |
Value
Get the Value attribute of the current web element (For Input text box for example)
Declaration
public string Value { get; }
Property Value
Type | Description |
---|---|
System.String |
Methods
| Improve this Doc View SourceApplyAttribute(FindsByAttribute)
Applies the locator defined in FindsByAttribute. this function is called automatically before InternalFindElements()
Declaration
public abstract void ApplyAttribute(FindsByAttribute attr)
Parameters
Type | Name | Description |
---|---|---|
FindsByAttribute | attr |
Clear()
Clear the content of the current web element. (for text-box and text areas)
Declaration
public void Clear()
Click()
Click on Web element.
Declaration
public void Click()
Exists()
Check if the given element exists on the screen
Declaration
public bool Exists()
Returns
Type | Description |
---|---|
System.Boolean | true if the element exists, otherwise: false |
Exists(Int32)
Check if the given element exists on the screen, with given sychronization timeout.
Declaration
public bool Exists(int timeoutSecond)
Parameters
Type | Name | Description |
---|---|---|
System.Int32 | timeoutSecond | object synchronization timeout in second. |
Returns
Type | Description |
---|---|
System.Boolean | True is the element exists in the current web page, Otherwise False |
FindElement()
Gets The IWebElement with current element description, using default timeout
Declaration
public IWebElement FindElement()
Returns
Type | Description |
---|---|
OpenQA.Selenium.IWebElement | The Web element localized by the description. |
Remarks
Default timeout is
FindElement(By)
Find a sub-element of the current element, with default synchronization timeout.
Declaration
public IWebElement FindElement(By by)
Parameters
Type | Name | Description |
---|---|---|
OpenQA.Selenium.By | by | Mecanism of find sub-elements |
Returns
Type | Description |
---|---|
OpenQA.Selenium.IWebElement | The indentified web element. |
FindElement(By, Int32)
Find the first element within the context of the current element. with provided synchronization timeout
Declaration
public IWebElement FindElement(By by, int timeoutSecond)
Parameters
Type | Name | Description |
---|---|---|
OpenQA.Selenium.By | by | Mecanism of find elements. |
System.Int32 | timeoutSecond | synchronization timeout in second. |
Returns
Type | Description |
---|---|
OpenQA.Selenium.IWebElement |
FindElement(Int32)
Gets the Web Element using curent element description, with customized timeout.
Declaration
public IWebElement FindElement(int timeoutSecond)
Parameters
Type | Name | Description |
---|---|---|
System.Int32 | timeoutSecond | object syncchronization timeout in second. |
Returns
Type | Description |
---|---|
OpenQA.Selenium.IWebElement | The indentified web element. |
FindElements()
This method find all possible elements given the current selection criteria. If there is no element match an OpenQA.Selenium.NoSuchElementException will be thrown
Declaration
public IReadOnlyCollection<IWebElement> FindElements()
Returns
Type | Description |
---|---|
System.Collections.Generic.IReadOnlyCollection<OpenQA.Selenium.IWebElement> | A collection of OpenQA.Selenium.IWebElement matches the element selection criteria |
FindElements(By)
Find elements within the context of the current element.
Declaration
public IReadOnlyCollection<IWebElement> FindElements(By by)
Parameters
Type | Name | Description |
---|---|---|
OpenQA.Selenium.By | by | Mecanism of find elements |
Returns
Type | Description |
---|---|
System.Collections.Generic.IReadOnlyCollection<OpenQA.Selenium.IWebElement> |
FindElements(Int32)
This method find all possible elements given the current selection criteria. If there is no element match an OpenQA.Selenium.NoSuchElementException will be thrown
Declaration
public IReadOnlyCollection<IWebElement> FindElements(int timeoutSecond)
Parameters
Type | Name | Description |
---|---|---|
System.Int32 | timeoutSecond | Timeout in seconds |
Returns
Type | Description |
---|---|
System.Collections.Generic.IReadOnlyCollection<OpenQA.Selenium.IWebElement> | A collection of OpenQA.Selenium.IWebElement matches the element selection criteria |
GetAttribute(String)
Get the value of the specified DOM attribute of this element.
Declaration
public string GetAttribute(string attributeName)
Parameters
Type | Name | Description |
---|---|---|
System.String | attributeName | the name of Html DOM attribute. |
Returns
Type | Description |
---|---|
System.String | The value of the indicated attribute. |
GetProperty(String)
Get the value of the specified DOM property of this element. for example GetProperty("value") will get the current value of a textbox
Declaration
public string GetProperty(string propertyName)
Parameters
Type | Name | Description |
---|---|---|
System.String | propertyName | the name of Html Property. |
Returns
Type | Description |
---|---|
System.String | The value of the indicated attribute. |
GetScreenshot()
Generates an screenshot of this specific element
Declaration
public byte[] GetScreenshot()
Returns
Type | Description |
---|---|
System.Byte[] | The screenshot image in RAW Binary data format. |
GetText()
Get the Text attribute of the current web element.
Declaration
public string GetText()
Returns
Type | Description |
---|---|
System.String | The Text of the current web element |
InternalClick()
Default behavior of Click
Declaration
protected virtual void InternalClick()
InternalFindElement()
Implemente element identifying algorithm, without the need of object synchronization.
Declaration
protected abstract IWebElement InternalFindElement()
Returns
Type | Description |
---|---|
OpenQA.Selenium.IWebElement | Identified test object. |
InternalFindElements()
Implemente element identifying algorithm, without the need of object synchronization.
Declaration
protected abstract IReadOnlyCollection<IWebElement> InternalFindElements()
Returns
Type | Description |
---|---|
System.Collections.Generic.IReadOnlyCollection<OpenQA.Selenium.IWebElement> | Identified test objects |
InternalGetScreenshot()
Implemente screenshot generation for the current specific element
Declaration
protected abstract byte[] InternalGetScreenshot()
Returns
Type | Description |
---|---|
System.Byte[] | The screenshot image in RAW Binary data format. |
Perform(Action)
Perform a secured action that may be influnced by web application reload behavoirs to avoid errors, such as OpenQA.Selenium.StaleElementReferenceException
Declaration
protected void Perform(Action action)
Parameters
Type | Name | Description |
---|---|---|
System.Action | action | The action to be performed. The name of the method |
Perform(Action<Int32>, Int32)
Perform a secured action that may be influnced by web application reload behavoirs to avoid errors, such as OpenQA.Selenium.StaleElementReferenceException
Declaration
protected void Perform(Action<int> action, int param)
Parameters
Type | Name | Description |
---|---|---|
System.Action<System.Int32> | action | The action to be performed. The name of the method |
System.Int32 | param | The parameter of the delegated method |
Perform(Action<String>, String)
Perform a secured action that may be influnced by web application reload behavoirs to avoid errors, such as OpenQA.Selenium.StaleElementReferenceException
Declaration
protected void Perform(Action<string> action, string param)
Parameters
Type | Name | Description |
---|---|---|
System.Action<System.String> | action | The action to be performed. The name of the method |
System.String | param | The parameter of the delegated method |
Perform(Func<Boolean>)
Perform a secured action that may be influnced by web application reload behavoirs to avoid errors, such as OpenQA.Selenium.StaleElementReferenceException
Declaration
protected bool Perform(Func<bool> action)
Parameters
Type | Name | Description |
---|---|---|
System.Func<System.Boolean> | action | The action to be performed. The name of the method |
Returns
Type | Description |
---|---|
System.Boolean | value returned by underlying method |
Perform(Func<Byte[]>)
Perform an action which returns an screenshot of the given element or context
Declaration
protected byte[] Perform(Func<byte[]> action)
Parameters
Type | Name | Description |
---|---|---|
System.Func<System.Byte[]> | action | Delegation which returns an screenshot |
Returns
Type | Description |
---|---|
System.Byte[] | A screenshot of given element or context. |
Perform(Func<String, IWebElement>, String)
Perform a secured action that may be influnced by web application reload behavoirs to avoid errors, such as OpenQA.Selenium.StaleElementReferenceException
Declaration
protected IWebElement Perform(Func<string, IWebElement> action, string param)
Parameters
Type | Name | Description |
---|---|---|
System.Func<System.String, OpenQA.Selenium.IWebElement> | action | The action to be performed. The name of the method |
System.String | param | The parameter of the action. |
Returns
Type | Description |
---|---|
OpenQA.Selenium.IWebElement |
Perform(Func<String, String>, String)
Perform a secured action that may be influnced by web application reload behavoirs to avoid errors, such as OpenQA.Selenium.StaleElementReferenceException
Declaration
protected string Perform(Func<string, string> action, string param)
Parameters
Type | Name | Description |
---|---|---|
System.Func<System.String, System.String> | action | The action to be performed. The name of the method |
System.String | param | The parameter of the delegated method |
Returns
Type | Description |
---|---|
System.String | value returned by underlying method |
Perform(Func<String>)
Perform a secured action that may be influnced by web application reload behavoirs to avoid errors, such as OpenQA.Selenium.StaleElementReferenceException
Declaration
protected string Perform(Func<string> action)
Parameters
Type | Name | Description |
---|---|---|
System.Func<System.String> | action | The action to be performed. The name of the method |
Returns
Type | Description |
---|---|
System.String | value returned by underlying method |
SendKeys(String)
Send keys (text) to the current web element. (for textbox or text areas). Sendkeys does not clear the current value in the textbox or text areas. The text will be inserted according to the cursor location. If you want to ensure the textbox contains exactly the value you want to set, use the function SetValue(String)
Declaration
public void SendKeys(string text)
Parameters
Type | Name | Description |
---|---|---|
System.String | text | the text to send |
SetValue(String)
Set the value of the current web element. For textbox or text areas. SetValue clears existing value in the textbox or text area before input the text in it. If you want to append or insert the text without clearing current value, use the function SendKeys(String)
Declaration
public void SetValue(string text)
Parameters
Type | Name | Description |
---|---|---|
System.String | text | The text to set. |
UseDriver(WebDriver)
Sets the Selenium WebDriver to use for object indentification. If the WebElement is declared within a PageModel there is no need to apply the WebDriver to use.
Declaration
public ElementDescription UseDriver(WebDriver driver)
Parameters
Type | Name | Description |
---|---|---|
OpenQA.Selenium.WebDriver | driver | WebDriver to be used to locate objects |
Returns
Type | Description |
---|---|
ElementDescription |