-
-
Notifications
You must be signed in to change notification settings - Fork 184
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
6bd3ef2
commit eae1817
Showing
16 changed files
with
155 additions
and
69 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
28 changes: 17 additions & 11 deletions
28
example/java/src/test/java/example/appium/FlutterTest.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,19 +1,25 @@ | ||
package example.appium; | ||
|
||
import org.junit.Before; | ||
import org.junit.Test; | ||
import pro.truongsinh.appium_flutter.finder.Finder; | ||
import org.openqa.selenium.By; | ||
import org.openqa.selenium.WebElement; | ||
|
||
import java.util.List; | ||
import pro.truongsinh.appium_flutter.FlutterFinder; | ||
|
||
import static org.junit.Assert.assertEquals; | ||
|
||
public class FlutterTest extends BaseDriver{ | ||
@Test | ||
public void simpleTest(){ | ||
String a = Finder.text("input"); | ||
System.out.println(a); | ||
} | ||
import io.appium.java_client.MobileElement; | ||
|
||
public class FlutterTest extends BaseDriver { | ||
protected FlutterFinder finder; | ||
@Before | ||
public void setUp() throws Exception { | ||
super.setUp(); | ||
finder = new FlutterFinder(driver); | ||
} | ||
@Test | ||
public void basicTest () throws InterruptedException { | ||
MobileElement el1 = finder.byValueKey("increment"); | ||
el1.click(); | ||
Thread.sleep(1000); | ||
} | ||
|
||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
68 changes: 68 additions & 0 deletions
68
finder/kotlin/src/main/kotlin/pro/truongsinh/appium_flutter/FlutterFinder.kt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,68 @@ | ||
package pro.truongsinh.appium_flutter | ||
|
||
import io.appium.java_client.MobileElement | ||
import org.openqa.selenium.remote.RemoteWebDriver | ||
import pro.truongsinh.appium_flutter.finder.FlutterElement | ||
import pro.truongsinh.appium_flutter.finder.ancestor as _ancestor | ||
import pro.truongsinh.appium_flutter.finder.bySemanticsLabel as _bySemanticsLabel | ||
import pro.truongsinh.appium_flutter.finder.byTooltip as _byTooltip | ||
import pro.truongsinh.appium_flutter.finder.byType as _byType | ||
import pro.truongsinh.appium_flutter.finder.byValueKey as _byValueKey | ||
import pro.truongsinh.appium_flutter.finder.descendant as _descendant | ||
import pro.truongsinh.appium_flutter.finder.pageback as _pageback | ||
import pro.truongsinh.appium_flutter.finder.text as _text | ||
|
||
|
||
public class FlutterFinder(driver: RemoteWebDriver) { | ||
private val driver = driver | ||
fun ancestor(of: FlutterElement, matching: FlutterElement, matchRoot: Boolean = false): FlutterElement { | ||
val f = _ancestor(of, matching, matchRoot) | ||
f.setParent(driver) | ||
return f | ||
} | ||
fun bySemanticsLabel(label: String): FlutterElement { | ||
val f = _bySemanticsLabel(label) | ||
f.setParent(driver) | ||
return f | ||
} | ||
fun bySemanticsLabel(label: Regex): FlutterElement { | ||
val f = _bySemanticsLabel(label) | ||
f.setParent(driver) | ||
return f | ||
} | ||
fun byTooltip(input: String): FlutterElement { | ||
val f = _byTooltip(input) | ||
f.setParent(driver) | ||
return f | ||
} | ||
fun byType(input: String): FlutterElement { | ||
val f = _byType(input) | ||
f.setParent(driver) | ||
return f | ||
} | ||
fun byValueKey(input: String): FlutterElement { | ||
val f = _byValueKey(input) | ||
f.setParent(driver) | ||
return f | ||
} | ||
fun byValueKey(input: Int): FlutterElement { | ||
val f = _byValueKey(input) | ||
f.setParent(driver) | ||
return f | ||
} | ||
fun descendant(of: FlutterElement, matching: FlutterElement, matchRoot: Boolean = false): FlutterElement { | ||
val f = _descendant(of, matching, matchRoot) | ||
f.setParent(driver) | ||
return f | ||
} | ||
fun pageback(): FlutterElement { | ||
val f = _pageback() | ||
f.setParent(driver) | ||
return f | ||
} | ||
fun text(input: String): FlutterElement { | ||
val f = _text(input) | ||
f.setParent(driver) | ||
return f | ||
} | ||
} |
12 changes: 12 additions & 0 deletions
12
finder/kotlin/src/main/kotlin/pro/truongsinh/appium_flutter/finder/FlutterElement.kt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,12 @@ | ||
package pro.truongsinh.appium_flutter.finder | ||
|
||
import io.appium.java_client.MobileElement | ||
|
||
public class FlutterElement : MobileElement { | ||
private var _rawMap: Map<String, *> | ||
constructor(m: Map<String, *>) { | ||
_rawMap = m | ||
id = serialize(m) | ||
} | ||
fun getRawMap(): Map<String, *> { return _rawMap } | ||
} |
11 changes: 5 additions & 6 deletions
11
finder/kotlin/src/main/kotlin/pro/truongsinh/appium_flutter/finder/ancestor.kt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,18 +1,17 @@ | ||
@file:JvmName("Finder") | ||
@file:JvmName("_FinderRawMethods") | ||
@file:JvmMultifileClass | ||
package pro.truongsinh.appium_flutter.finder | ||
|
||
fun ancestor(of: String, matching: String, matchRoot: Boolean = false): String { | ||
fun ancestor(of: FlutterElement, matching: FlutterElement, matchRoot: Boolean = false): FlutterElement { | ||
val m = mutableMapOf( | ||
"finderType" to "Ancestor", | ||
"matchRoot" to matchRoot | ||
) | ||
deserialize(of).forEach { | ||
print(it.value) | ||
of.getRawMap().forEach { | ||
m.put("of_${it.key}", it.value!!) | ||
} | ||
deserialize(matching).forEach { | ||
matching.getRawMap().forEach { | ||
m.put("matching_${it.key}", it.value!!) | ||
} | ||
return serialize(m) | ||
return FlutterElement(m) | ||
} |
12 changes: 5 additions & 7 deletions
12
finder/kotlin/src/main/kotlin/pro/truongsinh/appium_flutter/finder/bySemanticsLabel.kt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,21 +1,19 @@ | ||
@file:JvmName("Finder") | ||
@file:JvmName("_FinderRawMethods") | ||
@file:JvmMultifileClass | ||
package pro.truongsinh.appium_flutter.finder | ||
|
||
fun bySemanticsLabel(label: String): String { | ||
val base64Encoded = serialize(mapOf( | ||
fun bySemanticsLabel(label: String): FlutterElement { | ||
return FlutterElement(mapOf( | ||
"finderType" to "BySemanticsLabel", | ||
"isRegExp" to false, | ||
"label" to label | ||
)) | ||
return base64Encoded | ||
} | ||
|
||
fun bySemanticsLabel(label: Regex): String { | ||
val base64Encoded = serialize(mapOf( | ||
fun bySemanticsLabel(label: Regex): FlutterElement { | ||
return FlutterElement(mapOf( | ||
"finderType" to "BySemanticsLabel", | ||
"isRegExp" to true, | ||
"label" to label.toString() | ||
)) | ||
return base64Encoded | ||
} |
7 changes: 3 additions & 4 deletions
7
finder/kotlin/src/main/kotlin/pro/truongsinh/appium_flutter/finder/byTooltip.kt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,11 +1,10 @@ | ||
@file:JvmName("Finder") | ||
@file:JvmName("_FinderRawMethods") | ||
@file:JvmMultifileClass | ||
package pro.truongsinh.appium_flutter.finder | ||
|
||
fun byTooltip(input: String): String { | ||
val base64Encoded = serialize(mapOf( | ||
fun byTooltip(input: String): FlutterElement { | ||
return FlutterElement(mapOf( | ||
"finderType" to "ByTooltipMessage", | ||
"text" to input | ||
)) | ||
return base64Encoded | ||
} |
7 changes: 3 additions & 4 deletions
7
finder/kotlin/src/main/kotlin/pro/truongsinh/appium_flutter/finder/byType.kt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,11 +1,10 @@ | ||
@file:JvmName("Finder") | ||
@file:JvmName("_FinderRawMethods") | ||
@file:JvmMultifileClass | ||
package pro.truongsinh.appium_flutter.finder | ||
|
||
fun byType(input: String): String { | ||
val base64Encoded = serialize(mapOf( | ||
fun byType(input: String): FlutterElement { | ||
return FlutterElement(mapOf( | ||
"finderType" to "ByType", | ||
"type" to input | ||
)) | ||
return base64Encoded | ||
} |
12 changes: 5 additions & 7 deletions
12
finder/kotlin/src/main/kotlin/pro/truongsinh/appium_flutter/finder/byValueKey.kt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,21 +1,19 @@ | ||
@file:JvmName("Finder") | ||
@file:JvmName("_FinderRawMethods") | ||
@file:JvmMultifileClass | ||
package pro.truongsinh.appium_flutter.finder | ||
|
||
fun byValueKey(input: String): String { | ||
val base64Encoded = serialize(mapOf( | ||
fun byValueKey(input: String): FlutterElement { | ||
return FlutterElement(mapOf( | ||
"finderType" to "ByValueKey", | ||
"keyValueType" to "String", | ||
"keyValueString" to input | ||
)) | ||
return base64Encoded | ||
} | ||
|
||
fun byValueKey(input: Int): String { | ||
val base64Encoded = serialize(mapOf( | ||
fun byValueKey(input: Int): FlutterElement { | ||
return FlutterElement(mapOf( | ||
"finderType" to "ByValueKey", | ||
"keyValueType" to "int", | ||
"keyValueString" to input | ||
)) | ||
return base64Encoded | ||
} |
11 changes: 5 additions & 6 deletions
11
finder/kotlin/src/main/kotlin/pro/truongsinh/appium_flutter/finder/descendant.kt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,18 +1,17 @@ | ||
@file:JvmName("Finder") | ||
@file:JvmName("_FinderRawMethods") | ||
@file:JvmMultifileClass | ||
package pro.truongsinh.appium_flutter.finder | ||
|
||
fun descendant(of: String, matching: String, matchRoot: Boolean = false): String { | ||
fun descendant(of: FlutterElement, matching: FlutterElement, matchRoot: Boolean = false): FlutterElement { | ||
val m = mutableMapOf( | ||
"finderType" to "Descendant", | ||
"matchRoot" to matchRoot | ||
) | ||
deserialize(of).forEach { | ||
print(it.value) | ||
of.getRawMap().forEach { | ||
m.put("of_${it.key}", it.value!!) | ||
} | ||
deserialize(matching).forEach { | ||
matching.getRawMap().forEach { | ||
m.put("matching_${it.key}", it.value!!) | ||
} | ||
return serialize(m) | ||
return FlutterElement(m) | ||
} |
7 changes: 3 additions & 4 deletions
7
finder/kotlin/src/main/kotlin/pro/truongsinh/appium_flutter/finder/pageback.kt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,8 +1,7 @@ | ||
@file:JvmName("Finder") | ||
@file:JvmName("_FinderRawMethods") | ||
@file:JvmMultifileClass | ||
package pro.truongsinh.appium_flutter.finder | ||
|
||
fun pageback(): String { | ||
val base64Encoded = serialize(mapOf("finderType" to "PageBack")) | ||
return base64Encoded | ||
fun pageback(): FlutterElement { | ||
return FlutterElement(mapOf("finderType" to "PageBack")) | ||
} |
3 changes: 2 additions & 1 deletion
3
finder/kotlin/src/main/kotlin/pro/truongsinh/appium_flutter/finder/serializer.kt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
7 changes: 3 additions & 4 deletions
7
finder/kotlin/src/main/kotlin/pro/truongsinh/appium_flutter/finder/text.kt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,11 +1,10 @@ | ||
@file:JvmName("Finder") | ||
@file:JvmName("_FinderRawMethods") | ||
@file:JvmMultifileClass | ||
package pro.truongsinh.appium_flutter.finder | ||
|
||
fun text(input: String): String { | ||
val base64Encoded = serialize(mapOf( | ||
fun text(input: String): FlutterElement { | ||
return FlutterElement(mapOf( | ||
"finderType" to "ByText", | ||
"text" to input | ||
)) | ||
return base64Encoded | ||
} |
Oops, something went wrong.