Class ElementActions

Direct Known Subclasses:
Actions

public class ElementActions extends FluentWebDriverAction
  • Constructor Details

    • ElementActions

      public ElementActions()
    • ElementActions

      public ElementActions(org.openqa.selenium.WebDriver driver)
    • ElementActions

      public ElementActions(org.openqa.selenium.WebDriver driver, boolean isSilent)
    • ElementActions

      public ElementActions(DriverFactoryHelper helper)
  • Method Details

    • and

      public ElementActions and()
      Overrides:
      and in class FluentWebDriverAction
    • assertThat

      public WebDriverElementValidationsBuilder assertThat(org.openqa.selenium.By elementLocator)
    • verifyThat

      public WebDriverElementValidationsBuilder verifyThat(org.openqa.selenium.By elementLocator)
    • getElementsCount

      public int getElementsCount(org.openqa.selenium.By elementLocator)
    • getSelectedText

      public String getSelectedText(org.openqa.selenium.By elementLocator)
      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

      public ElementActions executeNativeMobileCommand(String command, Map<String,String> parameters)
      This is a generic method to enable the execution of the native mobile commands found herein: appium.io

      Note: 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

      public ElementActions click(org.openqa.selenium.By elementLocator)
      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

      public ElementActions clickUsingJavascript(org.openqa.selenium.By elementLocator)
      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

      public ElementActions 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.
      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

      public ElementActions clickAndHold(org.openqa.selenium.By elementLocator)
      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

      public ElementActions clipboardActions(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/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

      public ElementActions doubleClick(org.openqa.selenium.By elementLocator)
      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 ElementActions 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 ElementActions 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 moved
      yOffset - the vertical offset by which the element should be moved
      Returns:
      a self-reference to be used to chain actions
    • getAttribute

      public String getAttribute(org.openqa.selenium.By elementLocator, String attributeName)
      Get the value of the given attribute of the element. Will return the current value, even if this has been modified after the page has been loaded.

      More exactly, this method will return the value of the property with the given name, if it exists. If it does not, then the value of the attribute with the given name is returned. If neither exists, null is returned.

      The "style" attribute is converted as best can be to a text representation with a trailing semicolon.

      The following are deemed to be "boolean" attributes, and will return either "true" or null:

      async, autofocus, autoplay, checked, compact, complete, controls, declare, defaultchecked, defaultselected, defer, disabled, draggable, ended, formnovalidate, hidden, indeterminate, iscontenteditable, ismap, itemscope, loop, multiple, muted, nohref, noresize, noshade, novalidate, nowrap, open, paused, pubdate, readonly, required, reversed, scoped, seamless, seeking, selected, truespeed, willvalidate

      Finally, the following commonly mis-capitalized attribute/property names are evaluated as expected:

      If the given name is "class", the "className" property is returned. If the given name is "readonly", the "readOnly" property is returned. Note: The reason for this behavior is that users frequently confuse attributes and properties. If you need to do something more precise, e.g., refer to an attribute even when a property of the same name exists, then you should evaluate Javascript to obtain the result you desire.

      Parameters:
      elementLocator - the locator of the webElement under test (By xpath, id, selector, name ...etc.)
      attributeName - the target attribute of the webElement under test
      Returns:
      the value of the target attribute of the webElement under test
    • getCSSProperty

      public String getCSSProperty(org.openqa.selenium.By elementLocator, String propertyName)
      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

      public String getText(org.openqa.selenium.By elementLocator)
      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

      public ElementActions hover(org.openqa.selenium.By elementLocator)
      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 ElementActions 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
    • keyPress

      public ElementActions keyPress(org.openqa.selenium.By elementLocator, org.openqa.selenium.Keys key)
      Sends a key-press to the target element.
      Parameters:
      elementLocator - the locator of the webElement under test (By xpath, id, selector, name ...etc.)
      key - the key that should be pressed
      Returns:
      a self-reference to be used to chain actions
    • select

      public ElementActions select(org.openqa.selenium.By elementLocator, String valueOrVisibleText)
      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

      public ElementActions setValueUsingJavaScript(org.openqa.selenium.By elementLocator, String value)
      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

      public ElementActions submitFormUsingJavaScript(org.openqa.selenium.By elementLocator)
      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

      public ElementActions switchToIframe(org.openqa.selenium.By elementLocator)
      Switches focus to a certain iFrame, is mainly used in coordination with switchToDefaultContent() 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

      public ElementActions switchToDefaultContent()
      Switches focus to default content, is mainly used in coordination with switchToIframe(By) to exit any iFrame layer and go back to the main page
      Returns:
      a self-reference to be used to chain actions
    • getCurrentFrame

      public String getCurrentFrame()
      gets the current frame
      Returns:
      currentFrame the current frame name
    • type

      public ElementActions type(org.openqa.selenium.By elementLocator, CharSequence text)
    • clear

      public ElementActions clear(org.openqa.selenium.By elementLocator)
    • typeAppend

      public ElementActions typeAppend(org.openqa.selenium.By elementLocator, String text)
      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

      public ElementActions 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.
      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

      public ElementActions typeSecure(org.openqa.selenium.By elementLocator, String text)
      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
    • waitToBeReady

      public ElementActions waitToBeReady(org.openqa.selenium.By elementLocator)
      Waits dynamically for a specific element to be present in DOM, and ready to interact with, on the current page.
      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
    • waitToBeReady

      public ElementActions waitToBeReady(org.openqa.selenium.By elementLocator, boolean isExpectedToBeVisible)
    • waitToBeInvisible

      public ElementActions waitToBeInvisible(org.openqa.selenium.By elementLocator)
      Waits dynamically for a specific element to be detached from DOM, or hidden, on the current page.
      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
    • waitForTextToChange

      public ElementActions waitForTextToChange(org.openqa.selenium.By elementLocator, String initialValue)
      Waits dynamically for a specific element's text to change from the initial value to a new unknown value. Waits until the default element identification timeout
      Parameters:
      elementLocator - the locator of the webElement under test (By xpath, id, selector, name ...etc.)
      initialValue - the initial text value of the target webElement
      Returns:
      a self-reference to be used to chain actions
    • waitToAttribute

      public ElementActions waitToAttribute(org.openqa.selenium.By elementLocator, String attribute, String expectedValue)
      Waits dynamically for a specific element's attribute to be a certain value. Waits until the default element identification timeout
      Parameters:
      elementLocator - the locator of the webElement under test (By xpath, id, selector, name ...etc.)
      attribute - the attribute name of the target webElement
      expectedValue - the expected value of the attribute
      Returns:
      a self-reference to be used to chain actions
    • isElementDisplayed

      public boolean isElementDisplayed(org.openqa.selenium.By elementLocator)
      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

      public boolean isElementClickable(org.openqa.selenium.By elementLocator)
      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

      public List<Map<String,String>> 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 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

      public ElementActions captureScreenshot(org.openqa.selenium.By elementLocator)
    • waitUntilNumberOfElementsToBe

      public ElementActions waitUntilNumberOfElementsToBe(org.openqa.selenium.By elementLocator, int numberOfElements)
    • waitUntilNumberOfElementsToBeLessThan

      public ElementActions waitUntilNumberOfElementsToBeLessThan(org.openqa.selenium.By elementLocator, int numberOfElements)
    • waitUntilNumberOfElementsToBeMoreThan

      public ElementActions waitUntilNumberOfElementsToBeMoreThan(org.openqa.selenium.By elementLocator, int numberOfElements)
    • waitUntilAttributeContains

      public ElementActions waitUntilAttributeContains(org.openqa.selenium.By elementLocator, String attribute, String attributeContainsValue)
    • waitUntilElementTextToBe

      public ElementActions waitUntilElementTextToBe(org.openqa.selenium.By elementLocator, String text)
    • waitUntilElementToBeSelected

      public ElementActions waitUntilElementToBeSelected(org.openqa.selenium.By elementLocator)
    • waitUntilPresenceOfAllElementsLocatedBy

      public ElementActions waitUntilPresenceOfAllElementsLocatedBy(org.openqa.selenium.By elementLocator)