Skip to content
This repository has been archived by the owner on Oct 10, 2024. It is now read-only.

Added optional offset to tap action #31

Merged
merged 4 commits into from
Sep 12, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion uiTestGlaze/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ plugins {

ext {
PUBLISH_GROUP_ID = 'io.github.getyourguide'
PUBLISH_VERSION = '1.1.0'
PUBLISH_VERSION = '1.1.1'
PUBLISH_ARTIFACT_ID = 'uitestglaze'
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,8 @@ internal class TapHelper(
optional: Boolean,
retryCount: Int,
longPress: Boolean,
offsetX: Int,
offsetY: Int,
hierarchy: TreeNode,
device: UiDevice,
) {
Expand All @@ -24,19 +26,21 @@ internal class TapHelper(
optional,
device,
) ?: return
tapOnTreeNode(foundUiElement, optional, retryCount, longPress, device)
tapOnTreeNode(foundUiElement, optional, retryCount, longPress, offsetX, offsetY, device)
}

private fun tapOnTreeNode(
uiElement: UiElement,
optional: Boolean,
retryCount: Int,
longPress: Boolean,
offsetX: Int,
offsetY: Int,
device: UiDevice,
) {
tap(
uiElement.x + (uiElement.width) / 2,
uiElement.y + (uiElement.height) / 2,
uiElement.x + (uiElement.width) / 2 + offsetX,
uiElement.y + (uiElement.height) / 2 + offsetY,
optional,
retryCount,
longPress,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -93,6 +93,8 @@ data class UiTestGlaze(
optional: Boolean = false,
retryCount: Int = 3,
longPress: Boolean = false,
offsetX: Int = 0,
offsetY: Int = 0,
) {
val hierarchy =
hierarchySettleHelper.waitTillHierarchySettles(
Expand All @@ -101,7 +103,7 @@ data class UiTestGlaze(
config.waitTillLoadingViewsGoneTimeout,
config.waitTillHierarchySettlesTimeout,
)
tapHelper.tap(uiElementIdentifier, optional, retryCount, longPress, hierarchy, device)
tapHelper.tap(uiElementIdentifier, optional, retryCount, longPress, offsetX, offsetY, hierarchy, device)
}

/**
Expand Down