Skip to content

Commit 31c7c8a

Browse files
committed
resolve most todos
1 parent 85bc560 commit 31c7c8a

File tree

7 files changed

+40
-29
lines changed

7 files changed

+40
-29
lines changed

example/java/pom.xml

+1-1
Original file line numberDiff line numberDiff line change
@@ -52,7 +52,7 @@
5252
<dependency>
5353
<groupId>pro.truongsinh</groupId>
5454
<artifactId>appium-flutter-finder</artifactId>
55-
<version>0.0.2</version>
55+
<version>0.0.3</version>
5656
</dependency>
5757

5858
</dependencies>

example/java/src/test/java/example/appium/FlutterTest.java

+6-11
Original file line numberDiff line numberDiff line change
@@ -7,11 +7,11 @@
77
import java.util.HashMap;
88
import java.util.List;
99
import java.util.Map;
10+
import java.util.regex.Pattern;
1011
import java.io.File;
1112

1213
import org.openqa.selenium.OutputType;
1314
import io.appium.java_client.MobileElement;
14-
import kotlin.text.Regex;
1515
import pro.truongsinh.appium_flutter.FlutterFinder;
1616

1717
public class FlutterTest extends BaseDriver {
@@ -71,8 +71,7 @@ public void basicTest () throws InterruptedException {
7171

7272
find.byTooltip("Increment").click();
7373

74-
// @todo param override
75-
assertEquals(find.descendant(find.byTooltip("counter_tooltip"), find.byValueKey("counter"), false).getText(), "3");
74+
assertEquals(find.descendant(find.byTooltip("counter_tooltip"), find.byValueKey("counter")).getText(), "3");
7675

7776
find.byType("FlatButton").click();
7877
driver.executeScript("flutter:waitForAbsent", buttonFinder);
@@ -101,19 +100,15 @@ public void basicTest () throws InterruptedException {
101100
driver.executeScript("flutter:enterText", "I can enter text"); // enter text
102101
driver.executeScript("flutter:waitFor", find.text("I can enter text")); // verify text appears on UI
103102

104-
// @todo should be `pageBack`
105-
find.pageback().click();
103+
find.pageBack().click();
106104
driver.executeScript("flutter:waitFor", buttonFinder);
107105

108106
find.descendant(
109107
find.ancestor(
110-
// @todo should be Java Pattern
111-
find.bySemanticsLabel(new Regex("counter_semantic")),
112-
find.byType("Tooltip"),
113-
false
108+
find.bySemanticsLabel(Pattern.compile("counter_semantic")),
109+
find.byType("Tooltip")
114110
),
115-
find.byType("Text"),
116-
false
111+
find.byType("Text")
117112
)
118113
.click()
119114
;

finder/kotlin/build.gradle.kts

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
import org.gradle.jvm.tasks.Jar
22

33
group = "pro.truongsinh"
4-
version = "0.0.2"
4+
version = "0.0.3"
55

66
plugins {
77
id("kotlinx-serialization") version "1.3.40"

finder/kotlin/src/main/kotlin/pro/truongsinh/appium_flutter/FlutterFinder.kt

+16-4
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,7 @@
11
package pro.truongsinh.appium_flutter
22

3+
import java.util.regex.Pattern;
4+
35
import io.appium.java_client.MobileElement
46
import org.openqa.selenium.remote.RemoteWebDriver
57
import pro.truongsinh.appium_flutter.finder.FlutterElement
@@ -9,7 +11,7 @@ import pro.truongsinh.appium_flutter.finder.byTooltip as _byTooltip
911
import pro.truongsinh.appium_flutter.finder.byType as _byType
1012
import pro.truongsinh.appium_flutter.finder.byValueKey as _byValueKey
1113
import pro.truongsinh.appium_flutter.finder.descendant as _descendant
12-
import pro.truongsinh.appium_flutter.finder.pageback as _pageback
14+
import pro.truongsinh.appium_flutter.finder.pageBack as _pageBack
1315
import pro.truongsinh.appium_flutter.finder.text as _text
1416

1517

@@ -20,12 +22,17 @@ public class FlutterFinder(driver: RemoteWebDriver) {
2022
f.setParent(driver)
2123
return f
2224
}
25+
fun ancestor(of: FlutterElement, matching: FlutterElement): FlutterElement {
26+
val f = _ancestor(of, matching)
27+
f.setParent(driver)
28+
return f
29+
}
2330
fun bySemanticsLabel(label: String): FlutterElement {
2431
val f = _bySemanticsLabel(label)
2532
f.setParent(driver)
2633
return f
2734
}
28-
fun bySemanticsLabel(label: Regex): FlutterElement {
35+
fun bySemanticsLabel(label: Pattern): FlutterElement {
2936
val f = _bySemanticsLabel(label)
3037
f.setParent(driver)
3138
return f
@@ -55,8 +62,13 @@ public class FlutterFinder(driver: RemoteWebDriver) {
5562
f.setParent(driver)
5663
return f
5764
}
58-
fun pageback(): FlutterElement {
59-
val f = _pageback()
65+
fun descendant(of: FlutterElement, matching: FlutterElement): FlutterElement {
66+
val f = _descendant(of, matching)
67+
f.setParent(driver)
68+
return f
69+
}
70+
fun pageBack(): FlutterElement {
71+
val f = _pageBack()
6072
f.setParent(driver)
6173
return f
6274
}

finder/kotlin/src/main/kotlin/pro/truongsinh/appium_flutter/finder/bySemanticsLabel.kt

+3-1
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,8 @@
22
@file:JvmMultifileClass
33
package pro.truongsinh.appium_flutter.finder
44

5+
import java.util.regex.Pattern;
6+
57
fun bySemanticsLabel(label: String): FlutterElement {
68
return FlutterElement(mapOf(
79
"finderType" to "BySemanticsLabel",
@@ -10,7 +12,7 @@ fun bySemanticsLabel(label: String): FlutterElement {
1012
))
1113
}
1214

13-
fun bySemanticsLabel(label: Regex): FlutterElement {
15+
fun bySemanticsLabel(label: Pattern): FlutterElement {
1416
return FlutterElement(mapOf(
1517
"finderType" to "BySemanticsLabel",
1618
"isRegExp" to true,

finder/kotlin/src/main/kotlin/pro/truongsinh/appium_flutter/finder/pageback.kt

+1-1
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,6 @@
22
@file:JvmMultifileClass
33
package pro.truongsinh.appium_flutter.finder
44

5-
fun pageback(): FlutterElement {
5+
fun pageBack(): FlutterElement {
66
return FlutterElement(mapOf("finderType" to "PageBack"))
77
}

finder/kotlin/src/test/kotlin/pro/truongsinh/appium_flutter/finder/FinderTest.kt

+12-10
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,7 @@
11
package pro.truongsinh.appium_flutter.finder
22

3+
import java.util.regex.Pattern;
4+
35
import org.junit.Assert.assertEquals
46
import org.junit.Test
57

@@ -8,12 +10,12 @@ class FinderTest {
810
val expected = "eyJmaW5kZXJUeXBlIjoiQW5jZXN0b3IiLCJtYXRjaFJvb3QiOmZhbHNlLCJvZl9maW5kZXJUeXBlIjoiQW5jZXN0b3IiLCJvZl9tYXRjaFJvb3QiOmZhbHNlLCJvZl9vZl9maW5kZXJUeXBlIjoiUGFnZUJhY2siLCJvZl9tYXRjaGluZ19maW5kZXJUeXBlIjoiUGFnZUJhY2siLCJtYXRjaGluZ19maW5kZXJUeXBlIjoiQW5jZXN0b3IiLCJtYXRjaGluZ19tYXRjaFJvb3QiOmZhbHNlLCJtYXRjaGluZ19vZl9maW5kZXJUeXBlIjoiUGFnZUJhY2siLCJtYXRjaGluZ19tYXRjaGluZ19maW5kZXJUeXBlIjoiUGFnZUJhY2sifQ"
911
val observed = ancestor(
1012
of = ancestor(
11-
of = pageback(),
12-
matching = pageback()
13+
of = pageBack(),
14+
matching = pageBack()
1315
),
1416
matching = ancestor(
15-
of = pageback(),
16-
matching = pageback()
17+
of = pageBack(),
18+
matching = pageBack()
1719
)
1820
).id
1921
assertEquals(expected, observed)
@@ -22,7 +24,7 @@ class FinderTest {
2224
assertEquals("eyJmaW5kZXJUeXBlIjoiQnlTZW1hbnRpY3NMYWJlbCIsImlzUmVnRXhwIjpmYWxzZSwibGFiZWwiOiJzaW1wbGUifQ", bySemanticsLabel("simple").id)
2325
}
2426
@Test fun TestBySemanticsLabelRegex() {
25-
assertEquals("eyJmaW5kZXJUeXBlIjoiQnlTZW1hbnRpY3NMYWJlbCIsImlzUmVnRXhwIjp0cnVlLCJsYWJlbCI6ImNvbXBsaWNhdGVkIn0", bySemanticsLabel(Regex("complicated")).id)
27+
assertEquals("eyJmaW5kZXJUeXBlIjoiQnlTZW1hbnRpY3NMYWJlbCIsImlzUmVnRXhwIjp0cnVlLCJsYWJlbCI6ImNvbXBsaWNhdGVkIn0", bySemanticsLabel(Pattern.compile("complicated")).id)
2628
}
2729
@Test fun TestByTooltip() {
2830
assertEquals("eyJmaW5kZXJUeXBlIjoiQnlUb29sdGlwTWVzc2FnZSIsInRleHQiOiJteVRleHQifQ", byTooltip("myText").id)
@@ -44,18 +46,18 @@ class FinderTest {
4446
val expected = "eyJmaW5kZXJUeXBlIjoiRGVzY2VuZGFudCIsIm1hdGNoUm9vdCI6ZmFsc2UsIm9mX2ZpbmRlclR5cGUiOiJEZXNjZW5kYW50Iiwib2ZfbWF0Y2hSb290IjpmYWxzZSwib2Zfb2ZfZmluZGVyVHlwZSI6IlBhZ2VCYWNrIiwib2ZfbWF0Y2hpbmdfZmluZGVyVHlwZSI6IlBhZ2VCYWNrIiwibWF0Y2hpbmdfZmluZGVyVHlwZSI6IkRlc2NlbmRhbnQiLCJtYXRjaGluZ19tYXRjaFJvb3QiOmZhbHNlLCJtYXRjaGluZ19vZl9maW5kZXJUeXBlIjoiUGFnZUJhY2siLCJtYXRjaGluZ19tYXRjaGluZ19maW5kZXJUeXBlIjoiUGFnZUJhY2sifQ"
4547
val observed = descendant(
4648
of = descendant(
47-
of = pageback(),
48-
matching = pageback()
49+
of = pageBack(),
50+
matching = pageBack()
4951
),
5052
matching = descendant(
51-
of = pageback(),
52-
matching = pageback()
53+
of = pageBack(),
54+
matching = pageBack()
5355
)
5456
).id
5557
assertEquals(expected, observed)
5658
}
5759
@Test fun testPageback() {
58-
assertEquals("eyJmaW5kZXJUeXBlIjoiUGFnZUJhY2sifQ", pageback().id)
60+
assertEquals("eyJmaW5kZXJUeXBlIjoiUGFnZUJhY2sifQ", pageBack().id)
5961
}
6062
@Test fun testText() {
6163
assertEquals("eyJmaW5kZXJUeXBlIjoiQnlUZXh0IiwidGV4dCI6IlRoaXMgaXMgMm5kIHJvdXRlIn0", text("This is 2nd route").id)

0 commit comments

Comments
 (0)