Class WebDriverActions<SELF extends WebDriverActions<SELF>>
- java.lang.Object
-
- com.tngtech.jgiven.base.StageBase<SELF>
-
- com.tngtech.jgiven.Stage<SELF>
-
- dev.aherscu.qa.jgiven.commons.utils.StageEx<SELF>
-
- dev.aherscu.qa.jgiven.commons.steps.GenericActions<WebDriverScenarioType,SELF>
-
- dev.aherscu.qa.jgiven.webdriver.steps.WebDriverActions<SELF>
-
- Type Parameters:
SELF
- the type of the subclass
- All Implemented Interfaces:
dev.aherscu.qa.jgiven.commons.model.ScenarioType<WebDriverScenarioType>
,dev.aherscu.qa.jgiven.commons.utils.MayAttachScreenshots<SELF>
@ThreadSafe public class WebDriverActions<SELF extends WebDriverActions<SELF>> extends dev.aherscu.qa.jgiven.commons.steps.GenericActions<WebDriverScenarioType,SELF> implements dev.aherscu.qa.jgiven.commons.utils.MayAttachScreenshots<SELF>
Generic browser actions.- Author:
- aherscu
-
-
Field Summary
Fields Modifier and Type Field Description protected ThreadLocal<dev.aherscu.qa.jgiven.commons.utils.WebDriverEx>
webDriver
Expected browser object.
-
Constructor Summary
Constructors Constructor Description WebDriverActions()
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description protected SELF
activating_application(String appId)
Activates specified application.SELF
attaching_screenshot()
SELF
attaching_screenshot(int delayMs)
SELF
clicking(Supplier<org.openqa.selenium.WebElement> elementSupplier)
Clicks a specified element, retrying as much as configured; the element is retrieved via specified supplier before each retry.SELF
clicking(org.openqa.selenium.By locator)
Clicks a specified element, retrying as much as configured; the element is retrieved via specified locator before each retry.SELF
clicking_once(Supplier<org.openqa.selenium.WebElement> elementSupplier)
SELF
clicking_once(org.openqa.selenium.By locator)
protected org.openqa.selenium.WebElement
element(org.openqa.selenium.By locator)
Finds an element by specified locator and brings it into view.List<org.openqa.selenium.WebElement>
elements(org.openqa.selenium.By locator)
Finds all elements matching specified locator.protected List<org.openqa.selenium.WebElement>
ensureElements(org.openqa.selenium.By locator)
Retrieves matching DOM elements by specified locator and context.SELF
forcefullyClicking(Supplier<org.openqa.selenium.WebElement> elementSupplier)
Clicks a specified element even if hidden or out of view, retrying as much as configured; the element is retrieved via specified supplier before each retry.SELF
forcefullyClicking(org.openqa.selenium.By locator)
Clicks a specified element even if hidden or out of view, retrying as much as configured; the element is retrieved via specified locator before each retry.protected boolean
hasElements(org.openqa.selenium.By locator)
Retrieves matching DOM elements by specified locator and context.protected SELF
hiding_keyboard()
Hides the keyboard by clicking on the screen.SELF
long_pressing(Supplier<org.openqa.selenium.WebElement> elementSupplier)
Long presses a specified element, retrying as much as configured; the element is retrieved via specified supplier before each retry.SELF
long_pressing(org.openqa.selenium.By locator)
Long presses a specified element, retrying as much as configured;the element is retrieved via specified locator before each retry.SELF
opening(String url)
SELF
opening(URI url)
Opens an URL into the given browser.SELF
rotating_device_to(org.openqa.selenium.ScreenOrientation orientation)
Rotates devices to specified orientation.protected org.openqa.selenium.WebElement
scrollIntoView(org.openqa.selenium.WebElement element)
Scrolls specified element into view.SELF
sending_application_to_background_for(Duration duration)
Sends the application to background for specified duration.SELF
submitting_the_form_containing(org.openqa.selenium.By locator)
Submits the form containing the specified field.protected SELF
switching_to_context(Predicate<String> byRule)
Switches to specified Appium context.protected SELF
switching_to_window(String nameOrHandle)
Switches to specified window.SELF
terminating_application(String appId)
Terminates the specified application.protected dev.aherscu.qa.jgiven.commons.utils.WebDriverEx
thisWebDriver()
SELF
typing_$_into(String value, Supplier<org.openqa.selenium.WebElement> elementSupplier)
Types into a field, clearing it before and hiding the keyboard afterwards.SELF
typing_$_into(String value, org.openqa.selenium.By locator)
Types into a field, clearing it before and hiding the keyboard afterwards.SELF
typing_$_into_without_clearing(String value, Supplier<org.openqa.selenium.WebElement> elementSupplier)
SELF
typing_$_into_without_clearing(String value, org.openqa.selenium.By locator)
-
Methods inherited from class dev.aherscu.qa.jgiven.commons.steps.GenericActions
comment, concatenate_$_files_from_$_into, deleting_directory, doing_nothing, doing_nothing, doing_nothing, failing_on_purpose_with, retrying, retrying, safely, safely
-
-
-
-
Field Detail
-
webDriver
@ExpectedScenarioState protected ThreadLocal<dev.aherscu.qa.jgiven.commons.utils.WebDriverEx> webDriver
Expected browser object.
-
-
Method Detail
-
attaching_screenshot
@Hidden public SELF attaching_screenshot()
- Specified by:
attaching_screenshot
in interfacedev.aherscu.qa.jgiven.commons.utils.MayAttachScreenshots<SELF extends WebDriverActions<SELF>>
-
attaching_screenshot
@Hidden public SELF attaching_screenshot(int delayMs)
- Specified by:
attaching_screenshot
in interfacedev.aherscu.qa.jgiven.commons.utils.MayAttachScreenshots<SELF extends WebDriverActions<SELF>>
-
clicking
public SELF clicking(org.openqa.selenium.By locator)
Clicks a specified element, retrying as much as configured; the element is retrieved via specified locator before each retry.- Parameters:
locator
- the element- Returns:
StageBase.self()
-
clicking
public SELF clicking(Supplier<org.openqa.selenium.WebElement> elementSupplier)
Clicks a specified element, retrying as much as configured; the element is retrieved via specified supplier before each retry.click
metric will be updated and includes locating the element and scrolling into view.- Parameters:
elementSupplier
- late-bound element- Returns:
StageBase.self()
-
clicking_once
public SELF clicking_once(org.openqa.selenium.By locator)
-
elements
@Hidden public List<org.openqa.selenium.WebElement> elements(org.openqa.selenium.By locator)
Finds all elements matching specified locator.locateTimer
metric will be updated not including the scrolling into view.- Parameters:
locator
- the locator- Returns:
- the element
-
forcefullyClicking
@As("clicking") public SELF forcefullyClicking(Supplier<org.openqa.selenium.WebElement> elementSupplier)
Clicks a specified element even if hidden or out of view, retrying as much as configured; the element is retrieved via specified supplier before each retry.click
metric will be updated and includes locating the element.- Parameters:
elementSupplier
- late-bound element- Returns:
StageBase.self()
-
forcefullyClicking
@As("clicking") public SELF forcefullyClicking(org.openqa.selenium.By locator)
Clicks a specified element even if hidden or out of view, retrying as much as configured; the element is retrieved via specified locator before each retry.- Parameters:
locator
- the element- Returns:
StageBase.self()
-
long_pressing
public SELF long_pressing(Supplier<org.openqa.selenium.WebElement> elementSupplier)
Long presses a specified element, retrying as much as configured; the element is retrieved via specified supplier before each retry.- Parameters:
elementSupplier
- late-bound element- Returns:
StageBase.self()
-
long_pressing
public SELF long_pressing(org.openqa.selenium.By locator)
Long presses a specified element, retrying as much as configured;the element is retrieved via specified locator before each retry.- Parameters:
locator
- the element- Returns:
StageBase.self()
-
opening
public SELF opening(URI url)
Opens an URL into the given browser.- Parameters:
url
- the URL to open- Returns:
StageBase.self()
-
rotating_device_to
public SELF rotating_device_to(org.openqa.selenium.ScreenOrientation orientation)
Rotates devices to specified orientation.- Parameters:
orientation
- the orientation- Returns:
- #self()
-
sending_application_to_background_for
public SELF sending_application_to_background_for(Duration duration)
Sends the application to background for specified duration.- Parameters:
duration
- the duration- Returns:
StageBase.self()
-
submitting_the_form_containing
public SELF submitting_the_form_containing(org.openqa.selenium.By locator)
Submits the form containing the specified field.- Parameters:
locator
- the field- Returns:
StageBase.self()
-
terminating_application
public SELF terminating_application(String appId)
Terminates the specified application.- Parameters:
appId
- the application identifier- Returns:
StageBase.self()
-
typing_$_into
public SELF typing_$_into(@Quoted String value, Supplier<org.openqa.selenium.WebElement> elementSupplier)
Types into a field, clearing it before and hiding the keyboard afterwards.- Parameters:
value
- the value to typeelementSupplier
- late-bound element- Returns:
StageBase.self()
-
typing_$_into
public SELF typing_$_into(@Quoted String value, org.openqa.selenium.By locator)
Types into a field, clearing it before and hiding the keyboard afterwards.- Parameters:
value
- the value to typelocator
- the field- Returns:
StageBase.self()
-
typing_$_into_without_clearing
public SELF typing_$_into_without_clearing(@Quoted String value, Supplier<org.openqa.selenium.WebElement> elementSupplier)
-
typing_$_into_without_clearing
public SELF typing_$_into_without_clearing(@Quoted String value, org.openqa.selenium.By locator)
-
activating_application
@Hidden protected SELF activating_application(String appId)
Activates specified application.- Parameters:
appId
- the application identifier- Returns:
StageBase.self()
-
element
@Hidden protected org.openqa.selenium.WebElement element(org.openqa.selenium.By locator)
Finds an element by specified locator and brings it into view. If the locator is matching multiple elements then the first one is returned.locateTimer
metric will be updated not including the scrolling into view.- Parameters:
locator
- the locator- Returns:
- the element
- Throws:
org.openqa.selenium.NoSuchElementException
- If no matching elements are found
-
ensureElements
@Hidden protected List<org.openqa.selenium.WebElement> ensureElements(org.openqa.selenium.By locator)
Retrieves matching DOM elements by specified locator and context. Retries several time if the count of elements is zero.locateTimer
metric will be updated.- Parameters:
locator
- the locator- Returns:
- list of DOM elements
-
hasElements
@Hidden protected boolean hasElements(org.openqa.selenium.By locator)
Retrieves matching DOM elements by specified locator and context. Retries several time if the count of elements is zero.locateTimer
metric will be updated.- Parameters:
locator
- the locator- Returns:
- true if there are matching DOM elements
-
hiding_keyboard
@Hidden protected SELF hiding_keyboard()
Hides the keyboard by clicking on the screen.- Returns:
StageBase.self()
-
scrollIntoView
@Hidden protected org.openqa.selenium.WebElement scrollIntoView(org.openqa.selenium.WebElement element)
Scrolls specified element into view.scrollIntoView
metric will be updated.- Overrides:
scrollIntoView
in classdev.aherscu.qa.jgiven.commons.utils.StageEx<SELF extends WebDriverActions<SELF>>
- Parameters:
element
- the element to scroll into view- Returns:
- the element
-
switching_to_context
@Hidden protected SELF switching_to_context(Predicate<String> byRule)
Switches to specified Appium context.- Parameters:
byRule
- naming rule of Appium context- Returns:
StageBase.self()
- Throws:
org.openqa.selenium.NoSuchContextException
- if no such context exists
-
switching_to_window
@Hidden protected SELF switching_to_window(@Hidden String nameOrHandle)
Switches to specified window.- Parameters:
nameOrHandle
- the name of the window- Returns:
StageBase.self()
-
thisWebDriver
protected final dev.aherscu.qa.jgiven.commons.utils.WebDriverEx thisWebDriver()
-
-