Skip to content

Commit

Permalink
apply formatting
Browse files Browse the repository at this point in the history
  • Loading branch information
atavism committed Oct 30, 2023
1 parent 86ffff3 commit 31f0c61
Show file tree
Hide file tree
Showing 2 changed files with 19 additions and 17 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -18,4 +18,4 @@ class MobileElement private constructor(lazyElement: Lazy<() -> WebElement?>, la
}
return el
}
}
}
34 changes: 18 additions & 16 deletions appium_kotlin/app/src/test/java/appium_kotlin/tests/MobileUtils.kt
Original file line number Diff line number Diff line change
@@ -1,18 +1,20 @@
package appium_kotlin.tests

import appium_kotlin.LANTERN_PACKAGE_ID
import io.appium.java_client.MobileBy
import org.openqa.selenium.By
import appium_kotlin.LANTERN_PACKAGE_ID

class MobileUtils {
companion object {
fun id(id: String): By {
// MobileBy is optimised for for Android and IOS UIs instead of the generic By mainly for web locators.
return MobileBy.id(addPackageId(id))
}
companion object {
fun id(id: String): By {
// MobileBy is optimised for for Android and IOS UIs instead of the generic By mainly for web locators.
return MobileBy.id(addPackageId(id))
}

fun androidTextByBuilder(
text: String, scroll: Boolean = true, searchType: SearchTextOperator = SearchTextOperator.EXACT
fun androidTextByBuilder(
text: String,
scroll: Boolean = true,
searchType: SearchTextOperator = SearchTextOperator.EXACT,
): By {
val elementByText = "UiSelector().${searchType.androidUiSelectorTextMethodName}(\"$text\")"
val scrollableElement = "UiScrollable(UiSelector().scrollable(true).instance(0)).scrollIntoView($elementByText)"
Expand All @@ -25,15 +27,15 @@ class MobileUtils {
return MobileBy.AndroidUIAutomator(selector)
}

enum class SearchTextOperator(val androidUiSelectorTextMethodName: String, val iOSOperator: String) {
MATCHES("textMatches", "MATCHES"),
EXACT("text", "=="),
CONTAINS("textContains", "CONTAINS"),
STARTS_WITH("textStartsWith", "BEGINSWITH")
}
enum class SearchTextOperator(val androidUiSelectorTextMethodName: String, val iOSOperator: String) {
MATCHES("textMatches", "MATCHES"),
EXACT("text", "=="),
CONTAINS("textContains", "CONTAINS"),
STARTS_WITH("textStartsWith", "BEGINSWITH"),
}

private fun addPackageId(id: String): String {
return if (id.contains(":")) id else "${LANTERN_PACKAGE_ID}$id"
}
}
}
}
}

0 comments on commit 31f0c61

Please sign in to comment.