Package com.shaft.gui.element
Class TouchActions
java.lang.Object
com.shaft.driver.internal.FluentWebDriverAction
com.shaft.gui.element.TouchActions
-
Nested Class Summary
Modifier and TypeClassDescriptionstatic enum
static enum
SwipeDirection; swiping UP means the screen will move downwardsstatic enum
static enum
static enum
-
Constructor Summary
ConstructorDescriptionTouchActions
(DriverFactoryHelper helper) TouchActions
(org.openqa.selenium.WebDriver driver) -
Method Summary
Modifier and TypeMethodDescriptionactivateAppFromBackground
(String appPackageName) Activates an app that has been previously deactivated or sent to the background.and()
assertThat
(org.openqa.selenium.By elementLocator) doubleTap
(org.openqa.selenium.By elementLocator) Double-Taps an element on a touch-enabled screenHides the device native soft keyboard.longTap
(org.openqa.selenium.By elementLocator) Performs a long-tap on an element to trigger the context menu on a touch-enabled screenSends a key-press via the device soft keyboard.pinchToZoom
(TouchActions.ZoomDirection zoomDirection) Attempts to zoom the current screen IN/ OUT in case of zoom enabled screen.rotate
(org.openqa.selenium.ScreenOrientation orientation) Rotate between portrait and landscape modesSend the currently active app to the background and leave the app deactivated.sendAppToBackground
(int secondsToSpendInTheBackground) Send the currently active app to the background, and return after a certain number of seconds.swipeByOffset
(org.openqa.selenium.By elementLocator, int xOffset, int yOffset) Swipes an element with the desired x and y offset.swipeElementIntoView
(String targetText) Attempts to scroll element into view using androidUIAutomatorswipeElementIntoView
(String elementReferenceScreenshot, TouchActions.SwipeDirection swipeDirection) Attempts to scroll element into view using the new W3C compliant actions for android and ios and AI for image identificationswipeElementIntoView
(String targetText, TouchActions.SwipeMovement movement) Attempts to scroll element into view using androidUIAutomatorswipeElementIntoView
(org.openqa.selenium.By targetElementLocator, TouchActions.SwipeDirection swipeDirection) Attempts to scroll the element into view in case of native mobile elements.swipeElementIntoView
(org.openqa.selenium.By scrollableElementLocator, String elementReferenceScreenshot, TouchActions.SwipeDirection swipeDirection) Attempts to scroll element into view using the new W3C compliant actions for android and ios and AI for image identificationswipeElementIntoView
(org.openqa.selenium.By scrollableElementLocator, org.openqa.selenium.By targetElementLocator, TouchActions.SwipeDirection swipeDirection) Attempts to scroll element into view using the new W3C compliant actions for android and iosswipeToElement
(org.openqa.selenium.By sourceElementLocator, org.openqa.selenium.By destinationElementLocator) Swipes the sourceElement onto the destinationElement on a touch-enabled screenTaps an element once on a touch-enabled screentap
(org.openqa.selenium.By elementLocator) Taps an element once on a touch-enabled screenverifyThat
(org.openqa.selenium.By elementLocator) waitUntilElementIsVisible
(String elementReferenceScreenshot) Waits until a specific element is now visible on the current screenMethods inherited from class com.shaft.driver.internal.FluentWebDriverAction
alert, browser, element, initialize, initialize, initialize, initialize, performAlertAction, performBrowserAction, performElementAction, performTouchAction, touch, waitUntil
-
Constructor Details
-
TouchActions
public TouchActions() -
TouchActions
public TouchActions(org.openqa.selenium.WebDriver driver) -
TouchActions
-
-
Method Details
-
and
- Overrides:
and
in classFluentWebDriverAction
-
assertThat
-
verifyThat
-
nativeKeyboardKeyPress
Sends a key-press via the device soft keyboard.- Parameters:
key
- the key that should be pressed- Returns:
- a self-reference to be used to chain actions
-
hideNativeKeyboard
Hides the device native soft keyboard.- Returns:
- a self-reference to be used to chain actions
-
tap
Taps an element once on a touch-enabled screen- Parameters:
elementReferenceScreenshot
- relative path to the reference image from the local object repository- Returns:
- a self-reference to be used to chain actions
-
tap
Taps an element once on a touch-enabled screen- 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
-
doubleTap
Double-Taps an element on a touch-enabled screen- 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
-
longTap
Performs a long-tap on an element to trigger the context menu on a touch-enabled screen- 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
-
sendAppToBackground
Send the currently active app to the background, and return after a certain number of seconds.- Parameters:
secondsToSpendInTheBackground
- number of seconds before returning to the app- Returns:
- a self-reference to be used to chain actions
-
sendAppToBackground
Send the currently active app to the background and leave the app deactivated.- Returns:
- a self-reference to be used to chain actions
-
activateAppFromBackground
Activates an app that has been previously deactivated or sent to the background.- Parameters:
appPackageName
- the full name for the app package that you want to activate. for example [com.apple.Preferences] or [io.appium.android.apis]- Returns:
- a self-reference to be used to chain actions
-
swipeToElement
public TouchActions swipeToElement(org.openqa.selenium.By sourceElementLocator, org.openqa.selenium.By destinationElementLocator) Swipes the sourceElement onto the destinationElement on a touch-enabled screen- Parameters:
sourceElementLocator
- the locator of the webElement that needs to be swiped (By xpath, id, selector, name ...etc.)destinationElementLocator
- the locator of the webElement that you'll drop the sourceElement on (By xpath, id, selector, name ...etc.)- Returns:
- a self-reference to be used to chain actions
-
swipeByOffset
Swipes an element with the desired x and y offset. Swiping direction is determined by the positive/negative nature of the offset. Swiping destination is determined by the value of the offset.- Parameters:
elementLocator
- the locator of the webElement under test (By xpath, id, selector, name ...etc.)xOffset
- the horizontal offset by which the element should be swiped. positive value is "right" and negative value is "left"yOffset
- the vertical offset by which the element should be swiped. positive value is "down" and negative value is "up"- Returns:
- a self-reference to be used to chain actions
-
swipeElementIntoView
public TouchActions swipeElementIntoView(org.openqa.selenium.By targetElementLocator, TouchActions.SwipeDirection swipeDirection) Attempts to scroll the element into view in case of native mobile elements.- Parameters:
targetElementLocator
- the locator of the webElement under test (By xpath, id, selector, name ...etc.)swipeDirection
- SwipeDirection.DOWN, UP, RIGHT, or LEFT- Returns:
- a self-reference to be used to chain actions
-
waitUntilElementIsVisible
Waits until a specific element is now visible on the current screen- Parameters:
elementReferenceScreenshot
- relative path to the reference image from the local object repository- Returns:
- a self-reference to be used to chain actions
-
swipeElementIntoView
public TouchActions swipeElementIntoView(String elementReferenceScreenshot, TouchActions.SwipeDirection swipeDirection) Attempts to scroll element into view using the new W3C compliant actions for android and ios and AI for image identification- Parameters:
elementReferenceScreenshot
- relative path to the reference image from the local object repositoryswipeDirection
- SwipeDirection.DOWN, UP, RIGHT, or LEFT- Returns:
- a self-reference to be used to chain actions
-
swipeElementIntoView
public TouchActions swipeElementIntoView(org.openqa.selenium.By scrollableElementLocator, String elementReferenceScreenshot, TouchActions.SwipeDirection swipeDirection) Attempts to scroll element into view using the new W3C compliant actions for android and ios and AI for image identification- Parameters:
scrollableElementLocator
- the locator of the container/view/scrollable webElement that the scroll action will be performed insideelementReferenceScreenshot
- relative path to the reference image from the local object repositoryswipeDirection
- SwipeDirection.DOWN, UP, RIGHT, or LEFT- Returns:
- a self-reference to be used to chain actions
-
swipeElementIntoView
public TouchActions swipeElementIntoView(org.openqa.selenium.By scrollableElementLocator, org.openqa.selenium.By targetElementLocator, TouchActions.SwipeDirection swipeDirection) Attempts to scroll element into view using the new W3C compliant actions for android and ios- Parameters:
scrollableElementLocator
- the locator of the container/view/scrollable webElement that the scroll action will be performed insidetargetElementLocator
- the locator of the webElement that you want to scroll to under test (By xpath, id, selector, name ...etc.)swipeDirection
- SwipeDirection.DOWN, UP, RIGHT, or LEFT- Returns:
- a self-reference to be used to chain actions
-
swipeElementIntoView
Attempts to scroll element into view using androidUIAutomator- Parameters:
targetText
- element text to be used to swipe it into view- Returns:
- a self-reference to be used to chain actions
-
swipeElementIntoView
Attempts to scroll element into view using androidUIAutomator- Parameters:
targetText
- element text to be used to swipe it into viewmovement
- SwipeMovement.VERTICAL or HORIZONTAL- Returns:
- a self-reference to be used to chain actions
-
rotate
Rotate between portrait and landscape modes- Parameters:
orientation
- ScreenOrientation.LANDSCAPE or PORTRAIT- Returns:
- a self-reference to be used to chain actions
-
pinchToZoom
Attempts to zoom the current screen IN/ OUT in case of zoom enabled screen.- Parameters:
zoomDirection
- ZoomDirection.IN or OUT- Returns:
- a self-reference to be used to chain actions
-