Package com.shaft.gui.element
Class ElementActions
java.lang.Object
com.shaft.driver.internal.FluentWebDriverAction
com.shaft.gui.element.ElementActions
- Direct Known Subclasses:
Actions
-
Constructor Summary
ConstructorsConstructorDescriptionElementActions
(DriverFactoryHelper helper) ElementActions
(org.openqa.selenium.WebDriver driver) ElementActions
(org.openqa.selenium.WebDriver driver, boolean isSilent) -
Method Summary
Modifier and TypeMethodDescriptionand()
assertThat
(org.openqa.selenium.By elementLocator) captureScreenshot
(org.openqa.selenium.By elementLocator) clear
(org.openqa.selenium.By elementLocator) click
(org.openqa.selenium.By elementLocator) Clicks on a certain element using Selenium WebDriver, or JavaScriptclickAndHold
(org.openqa.selenium.By elementLocator) Waits for the element to be clickable, and then clicks and holds it.clickUsingJavascript
(org.openqa.selenium.By elementLocator) Clicks on certain element using javaScript onlyclipboardActions
(org.openqa.selenium.By elementLocator, ClipboardAction action) Attempts to perform a native clipboard action on the text from a certain web element, like copy/cut/pastedoubleClick
(org.openqa.selenium.By elementLocator) Double-clicks on an element using Selenium WebDriver's Actions LibrarydragAndDrop
(org.openqa.selenium.By sourceElementLocator, org.openqa.selenium.By destinationElementLocator) Drags the source element and drops it onto the destination elementdragAndDropByOffset
(org.openqa.selenium.By sourceElementLocator, int xOffset, int yOffset) Drags the source element and drops it onto the determined offsetexecuteNativeMobileCommand
(String command, Map<String, String> parameters) This is a generic method to enable the execution of the native mobile commands found herein: appium.iogetAttribute
(org.openqa.selenium.By elementLocator, String attributeName) Deprecated.getCSSProperty
(org.openqa.selenium.By elementLocator, String propertyName) Deprecated.gets the current frameint
getElementsCount
(org.openqa.selenium.By elementLocator) getSelectedText
(org.openqa.selenium.By elementLocator) Deprecated.getTableRowsData
(org.openqa.selenium.By tableLocator) Get any simple table rows' data that has thead which include all the column labels and tbody which includes all table datagetText
(org.openqa.selenium.By elementLocator) Deprecated.hover
(org.openqa.selenium.By elementLocator) Hovers over target element.hoverAndClick
(List<org.openqa.selenium.By> hoverElementLocators, org.openqa.selenium.By clickableElementLocator) Hovers over the hoverElements in sequence then clicks the clickableElementboolean
isElementClickable
(org.openqa.selenium.By elementLocator) Deprecated.boolean
isElementDisplayed
(org.openqa.selenium.By elementLocator) Deprecated.scrollToElement
(org.openqa.selenium.By elementLocator) If the element is outside the viewport, scrolls the bottom of the element to the bottom of the viewport.Selects an element from a dropdown list using its displayed text or attribute ValuesetValueUsingJavaScript
(org.openqa.selenium.By elementLocator, String value) Used to SetProperty value for an element (hidden or visible) using javascriptsubmitFormUsingJavaScript
(org.openqa.selenium.By elementLocator) Used to submit a form using javascriptSwitches focus to default content, is mainly used in coordination withswitchToIframe(By)
to exit any iFrame layer and go back to the main pageswitchToIframe
(org.openqa.selenium.By elementLocator) Switches focus to a certain iFrame, is mainly used in coordination withswitchToDefaultContent()
to navigate inside any iFrame layer and go back to the main pagetype
(org.openqa.selenium.By elementLocator, CharSequence... text) typeAppend
(org.openqa.selenium.By elementLocator, CharSequence... text) Appends the required string into the target element, regardless of the current text value.typeFileLocationForUpload
(org.openqa.selenium.By elementLocator, String filePath) ValidationEnums the required file path into an input[type='file'] button, to successfully upload the target file.typeSecure
(org.openqa.selenium.By elementLocator, CharSequence... text) Checks if there is any text in an element, clears it, then types the required string into the target element.verifyThat
(org.openqa.selenium.By elementLocator) waitUntilAttributeContains
(org.openqa.selenium.By elementLocator, String attribute, String attributeContainsValue) Deprecated.waitUntilElementTextToBe
(org.openqa.selenium.By elementLocator, String text) Deprecated.waitUntilElementToBeSelected
(org.openqa.selenium.By elementLocator) Deprecated.waitUntilNumberOfElementsToBe
(org.openqa.selenium.By elementLocator, int numberOfElements) Deprecated.waitUntilNumberOfElementsToBeLessThan
(org.openqa.selenium.By elementLocator, int numberOfElements) Deprecated.waitUntilNumberOfElementsToBeMoreThan
(org.openqa.selenium.By elementLocator, int numberOfElements) Deprecated.waitUntilPresenceOfAllElementsLocatedBy
(org.openqa.selenium.By elementLocator) Deprecated.Methods inherited from class com.shaft.driver.internal.FluentWebDriverAction
alert, browser, element, initialize, initialize, initialize, initialize, performAlertAction, performBrowserAction, performElementAction, performTouchAction, touch
-
Constructor Details
-
ElementActions
public ElementActions() -
ElementActions
public ElementActions(org.openqa.selenium.WebDriver driver) -
ElementActions
public ElementActions(org.openqa.selenium.WebDriver driver, boolean isSilent) -
ElementActions
-
-
Method Details
-
and
- Overrides:
and
in classFluentWebDriverAction
-
assertThat
-
verifyThat
-
getElementsCount
public int getElementsCount(org.openqa.selenium.By elementLocator) -
getSelectedText
Deprecated.Deprecated useActions.GetElementInformation.selectedText(By)
instead Retrieves the selected text from the target drop-down list element and returns it as a string value.- Parameters:
elementLocator
- the locator of the webElement under test (By xpath, id, selector, name ...etc.)- Returns:
- the selected text of the target webElement
-
executeNativeMobileCommand
This is a generic method to enable the execution of the native mobile commands found herein: appium.ioNote: This method does no validation on the output of the executed JavaScript
- Parameters:
command
- the desired mobile command to be executed. e.g., "mobile: scroll"parameters
- a map of the key, value parameters for this command. e.g., ImmutableMap.of("direction", "down")- Returns:
- a self-reference to be used to chain actions
-
click
Clicks on a certain element using Selenium WebDriver, or JavaScript- Parameters:
elementLocator
- the locator of the webElement under test (By xpath, id, selector, name ...etc.)- Returns:
- a self-reference to be used to chain actions
-
clickUsingJavascript
Clicks on certain element using javaScript only- Parameters:
elementLocator
- the locator of the webElement under test (By xpath, id, selector, name ...etc.)- Returns:
- a self-reference to be used to chain actions
-
scrollToElement
If the element is outside the viewport, scrolls the bottom of the element to the bottom of the viewport.- Parameters:
elementLocator
- the locator of the webElement under test (By xpath, id, selector, name ...etc.)- Returns:
- a self-reference to be used to chain actions
-
clickAndHold
Waits for the element to be clickable, and then clicks and holds it.- Parameters:
elementLocator
- the locator of the webElement under test (By xpath, id, selector, name ...etc.)- Returns:
- a self-reference to be used to chain actions
-
clipboardActions
Attempts to perform a native clipboard action on the text from a certain web element, like copy/cut/paste- Parameters:
elementLocator
- the locator of the webElement under test (By xpath, id, selector, name ...etc.)action
- supports the following actions "copy", "paste", "cut", "select all", "unselect"- Returns:
- a self-reference to be used to chain actions
-
doubleClick
Double-clicks on an element using Selenium WebDriver's Actions Library- Parameters:
elementLocator
- the locator of the webElement under test (By xpath, id, selector, name ...etc.)- Returns:
- a self-reference to be used to chain actions
-
dragAndDrop
public Actions dragAndDrop(org.openqa.selenium.By sourceElementLocator, org.openqa.selenium.By destinationElementLocator) Drags the source element and drops it onto the destination element- Parameters:
sourceElementLocator
- the locator of the source webElement that should be dragged under test (By xpath, id, selector, name ...etc.)destinationElementLocator
- the locator of the target webElement that should receive the dropped source element under test (By xpath, id, selector, name ...etc.)- Returns:
- a self-reference to be used to chain actions
-
dragAndDropByOffset
public Actions dragAndDropByOffset(org.openqa.selenium.By sourceElementLocator, int xOffset, int yOffset) Drags the source element and drops it onto the determined offset- Parameters:
sourceElementLocator
- the locator of the source webElement that should be dragged under test (By xpath, id, selector, name ...etc.)xOffset
- the horizontal offset by which the element should be movedyOffset
- the vertical offset by which the element should be moved- Returns:
- a self-reference to be used to chain actions
-
getAttribute
Deprecated.Deprecated useActions.GetElementInformation.domProperty(By, String)
orActions.GetElementInformation.domAttribute(By, String)
instead- Parameters:
elementLocator
- the locator of the webElement under test (By xpath, id, selector, name ...etc.)attributeName
- the target DOM property of the webElement under test- Returns:
- the value of the target DOM property of the webElement under test
-
getCSSProperty
@Deprecated public String getCSSProperty(org.openqa.selenium.By elementLocator, String propertyName) Deprecated.Deprecated useActions.GetElementInformation.cssValue(By, String)
instead Get the value of a given CSS property. Color values should be returned as RGBA strings, so, for example if the "background-color" property is SetProperty as "green" in the HTML source, the returned value will be "RGBA(0, 255, 0, 1)". Note that shorthand CSS properties (e.g. background, font, border, border-top, margin, margin-top, padding, padding-top, list-style, outline, pause, cue) are not returned, in accordance with the DOM CSS2 specification - you should directly access the longhand properties (e.g. background-color) to access the desired values.- Parameters:
elementLocator
- the locator of the webElement under test (By xpath, id, selector, name ...etc.)propertyName
- the target CSS property of the webElement under test- Returns:
- the value of the target CSS property of the webElement under test
-
getText
Deprecated.Deprecated useActions.GetElementInformation.text(By)
instead Retrieves text from the target element and returns it as a string value.- Parameters:
elementLocator
- the locator of the webElement under test (By xpath, id, selector, name ...etc.)- Returns:
- the text value of the target webElement
-
hover
Hovers over target element. If you want to hover on a webElement to expose another webElement and click on it, use hoverAndClick instead for a more reliable result.- Parameters:
elementLocator
- the locator of the webElement under test (By xpath, id, selector, name ...etc.)- Returns:
- a self-reference to be used to chain actions
-
hoverAndClick
public Actions hoverAndClick(List<org.openqa.selenium.By> hoverElementLocators, org.openqa.selenium.By clickableElementLocator) Hovers over the hoverElements in sequence then clicks the clickableElement- Parameters:
hoverElementLocators
- the list of locators of the webElements under test upon which the hover action will be performed in sequence (By xpath, id, selector, name ...etc.)clickableElementLocator
- the locator of the webElement under test upon which the click action will be performed (By xpath, id, selector, name ...etc.)- Returns:
- a self-reference to be used to chain actions
-
select
Selects an element from a dropdown list using its displayed text or attribute Value- Parameters:
elementLocator
- the locator of the webElement under test (By xpath, id, selector, name ...etc.)valueOrVisibleText
- the text of the choice that you need to select from the target dropDown menu or the string value of attribute "value"- Returns:
- a self-reference to be used to chain actions
-
setValueUsingJavaScript
Used to SetProperty value for an element (hidden or visible) using javascript- Parameters:
elementLocator
- the locator of the webElement under test (By xpath, id, selector, name ...etc.)value
- the desired value that should be SetProperty for the target element- Returns:
- a self-reference to be used to chain actions
-
submitFormUsingJavaScript
Used to submit a form using javascript- Parameters:
elementLocator
- the locator of the webElement under test (By xpath, id, selector, name ...etc.)- Returns:
- a self-reference to be used to chain actions
-
switchToIframe
Switches focus to a certain iFrame, is mainly used in coordination withswitchToDefaultContent()
to navigate inside any iFrame layer and go back to the main page- Parameters:
elementLocator
- the locator of the iFrame webElement under test (By xpath, id, selector, name ...etc.)- Returns:
- a self-reference to be used to chain actions
-
switchToDefaultContent
Switches focus to default content, is mainly used in coordination withswitchToIframe(By)
to exit any iFrame layer and go back to the main page- Returns:
- a self-reference to be used to chain actions
-
getCurrentFrame
gets the current frame- Returns:
- currentFrame the current frame name
-
type
-
clear
-
typeAppend
Appends the required string into the target element, regardless of the current text value.- Parameters:
elementLocator
- the locator of the webElement under test (By xpath, id, selector, name ...etc.)text
- the target text that needs to be appended into the target webElement- Returns:
- a self-reference to be used to chain actions
-
typeFileLocationForUpload
ValidationEnums the required file path into an input[type='file'] button, to successfully upload the target file.- Parameters:
elementLocator
- the locator of the webElement under test (By xpath, id, selector, name ...etc.)filePath
- the full path to the file that needs to be uploaded, it can be absolute or relative path, Engine will detect that.- Returns:
- a self-reference to be used to chain actions.
-
typeSecure
Checks if there is any text in an element, clears it, then types the required string into the target element. Obfuscates the written text in the output report. This action should be used for writing passwords and secure text.- Parameters:
elementLocator
- the locator of the webElement under test (By xpath, id, selector, name ...etc.)text
- the target text that needs to be typed into the target webElement- Returns:
- a self-reference to be used to chain actions
-
isElementDisplayed
Deprecated.Deprecated useActions.GetElementInformation.isDisplayed(By)
instead Checks to see if an element is displayed- Parameters:
elementLocator
- the locator of the webElement under test (By xpath, id, selector, name ...etc.)- Returns:
- boolean value, true if the element is displayed, and false if the element is not displayed
-
isElementClickable
Deprecated.Deprecated useActions.GetElementInformation.isEnabled(By)
instead Checks to see if an element is clickable- Parameters:
elementLocator
- the locator of the webElement under test (By xpath, id, selector, name ...etc.)- Returns:
- boolean value, true if the element is clickable, and false if the element is not clickable
-
getTableRowsData
Get any simple table rows' data that has thead which include all the column labels and tbody which includes all table data- Parameters:
tableLocator
- the locator of the table which should be a table tag- Returns:
- List of Map format and each Map Object follows the following format (Key:column label, value: cell data)
-
captureScreenshot
-
waitUntilNumberOfElementsToBe
@Deprecated public Actions waitUntilNumberOfElementsToBe(org.openqa.selenium.By elementLocator, int numberOfElements) Deprecated. -
waitUntilNumberOfElementsToBeLessThan
@Deprecated public Actions waitUntilNumberOfElementsToBeLessThan(org.openqa.selenium.By elementLocator, int numberOfElements) Deprecated. -
waitUntilNumberOfElementsToBeMoreThan
@Deprecated public Actions waitUntilNumberOfElementsToBeMoreThan(org.openqa.selenium.By elementLocator, int numberOfElements) Deprecated. -
waitUntilAttributeContains
@Deprecated public Actions waitUntilAttributeContains(org.openqa.selenium.By elementLocator, String attribute, String attributeContainsValue) Deprecated. -
waitUntilElementTextToBe
@Deprecated public Actions waitUntilElementTextToBe(org.openqa.selenium.By elementLocator, String text) Deprecated. -
waitUntilElementToBeSelected
Deprecated. -
waitUntilPresenceOfAllElementsLocatedBy
@Deprecated public Actions waitUntilPresenceOfAllElementsLocatedBy(org.openqa.selenium.By elementLocator) Deprecated.
-