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
| Edit this page View Sourcedriver
WebDriver used to identify test objects.
Declaration
protected WebDriver driver
Field Value
| Type | Description |
|---|---|
| WebDriver |
Properties
| Edit this page 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 |
|---|---|
| bool | 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 |
|---|---|
| bool | 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 |
|---|---|
| bool | 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 |
|---|---|
| string |
Methods
| Edit this page 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 |
|---|---|
| bool | true if the element exists, otherwise: false |
Exists(int)
Check if the given element exists on the screen, with given sychronization timeout.
Declaration
public bool Exists(int timeoutSecond)
Parameters
| Type | Name | Description |
|---|---|---|
| int | timeoutSecond | object synchronization timeout in second. |
Returns
| Type | Description |
|---|---|
| bool | 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 |
|---|---|
| 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 |
|---|---|---|
| By | by | Mecanism of find sub-elements |
Returns
| Type | Description |
|---|---|
| IWebElement | The indentified web element. |
FindElement(By, int)
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 |
|---|---|---|
| By | by | Mecanism of find elements. |
| int | timeoutSecond | synchronization timeout in second. |
Returns
| Type | Description |
|---|---|
| IWebElement |
FindElement(int)
Gets the Web Element using curent element description, with customized timeout.
Declaration
public IWebElement FindElement(int timeoutSecond)
Parameters
| Type | Name | Description |
|---|---|---|
| int | timeoutSecond | object syncchronization timeout in second. |
Returns
| Type | Description |
|---|---|
| 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 |
|---|---|
| IReadOnlyCollection<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 |
|---|---|---|
| By | by | Mecanism of find elements |
Returns
| Type | Description |
|---|---|
| IReadOnlyCollection<IWebElement> |
FindElements(int)
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 |
|---|---|---|
| int | timeoutSecond | Timeout in seconds |
Returns
| Type | Description |
|---|---|
| IReadOnlyCollection<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 |
|---|---|---|
| string | attributeName | the name of Html DOM attribute. |
Returns
| Type | Description |
|---|---|
| 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 |
|---|---|---|
| string | propertyName | the name of Html Property. |
Returns
| Type | Description |
|---|---|
| string | The value of the indicated attribute. |
GetScreenshot()
Generates an screenshot of this specific element
Declaration
public byte[] GetScreenshot()
Returns
| Type | Description |
|---|---|
| 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 |
|---|---|
| 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 |
|---|---|
| IWebElement | Identified test object. |
InternalFindElements()
Implemente element identifying algorithm, without the need of object synchronization.
Declaration
protected abstract IReadOnlyCollection<IWebElement> InternalFindElements()
Returns
| Type | Description |
|---|---|
| IReadOnlyCollection<IWebElement> | Identified test objects |
InternalGetScreenshot()
Implemente screenshot generation for the current specific element
Declaration
protected abstract byte[] InternalGetScreenshot()
Returns
| Type | Description |
|---|---|
| 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 |
|---|---|---|
| Action | action | The action to be performed. The name of the method |
Perform(Action<int>, int)
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 |
|---|---|---|
| Action<int> | action | The action to be performed. The name of the method |
| int | 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 |
|---|---|---|
| Action<string> | action | The action to be performed. The name of the method |
| string | param | The parameter of the delegated method |
Perform(Func<bool>)
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 |
|---|---|---|
| Func<bool> | action | The action to be performed. The name of the method |
Returns
| Type | Description |
|---|---|
| bool | 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 |
|---|---|---|
| Func<byte[]> | action | Delegation which returns an screenshot |
Returns
| Type | Description |
|---|---|
| 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 |
|---|---|---|
| Func<string, IWebElement> | action | The action to be performed. The name of the method |
| string | param | The parameter of the action. |
Returns
| Type | Description |
|---|---|
| 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 |
|---|---|---|
| Func<string, string> | action | The action to be performed. The name of the method |
| string | param | The parameter of the delegated method |
Returns
| Type | Description |
|---|---|
| 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 |
|---|---|---|
| Func<string> | action | The action to be performed. The name of the method |
Returns
| Type | Description |
|---|---|
| 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 |
|---|---|---|
| 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 |
|---|---|---|
| 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 |
|---|---|---|
| WebDriver | driver | WebDriver to be used to locate objects |
Returns
| Type | Description |
|---|---|
| ElementDescription |