Skip to content

Commit

Permalink
resolve most todos
Browse files Browse the repository at this point in the history
  • Loading branch information
truongsinh committed Aug 21, 2019
1 parent 85bc560 commit 31c7c8a
Show file tree
Hide file tree
Showing 7 changed files with 40 additions and 29 deletions.
2 changes: 1 addition & 1 deletion example/java/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,7 @@
<dependency>
<groupId>pro.truongsinh</groupId>
<artifactId>appium-flutter-finder</artifactId>
<version>0.0.2</version>
<version>0.0.3</version>
</dependency>

</dependencies>
Expand Down
17 changes: 6 additions & 11 deletions example/java/src/test/java/example/appium/FlutterTest.java
Original file line number Diff line number Diff line change
Expand Up @@ -7,11 +7,11 @@
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import java.util.regex.Pattern;
import java.io.File;

import org.openqa.selenium.OutputType;
import io.appium.java_client.MobileElement;
import kotlin.text.Regex;
import pro.truongsinh.appium_flutter.FlutterFinder;

public class FlutterTest extends BaseDriver {
Expand Down Expand Up @@ -71,8 +71,7 @@ public void basicTest () throws InterruptedException {

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

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

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

// @todo should be `pageBack`
find.pageback().click();
find.pageBack().click();
driver.executeScript("flutter:waitFor", buttonFinder);

find.descendant(
find.ancestor(
// @todo should be Java Pattern
find.bySemanticsLabel(new Regex("counter_semantic")),
find.byType("Tooltip"),
false
find.bySemanticsLabel(Pattern.compile("counter_semantic")),
find.byType("Tooltip")
),
find.byType("Text"),
false
find.byType("Text")
)
.click()
;
Expand Down
2 changes: 1 addition & 1 deletion finder/kotlin/build.gradle.kts
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import org.gradle.jvm.tasks.Jar

group = "pro.truongsinh"
version = "0.0.2"
version = "0.0.3"

plugins {
id("kotlinx-serialization") version "1.3.40"
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
package pro.truongsinh.appium_flutter

import java.util.regex.Pattern;

import io.appium.java_client.MobileElement
import org.openqa.selenium.remote.RemoteWebDriver
import pro.truongsinh.appium_flutter.finder.FlutterElement
Expand All @@ -9,7 +11,7 @@ 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.pageBack as _pageBack
import pro.truongsinh.appium_flutter.finder.text as _text


Expand All @@ -20,12 +22,17 @@ public class FlutterFinder(driver: RemoteWebDriver) {
f.setParent(driver)
return f
}
fun ancestor(of: FlutterElement, matching: FlutterElement): FlutterElement {
val f = _ancestor(of, matching)
f.setParent(driver)
return f
}
fun bySemanticsLabel(label: String): FlutterElement {
val f = _bySemanticsLabel(label)
f.setParent(driver)
return f
}
fun bySemanticsLabel(label: Regex): FlutterElement {
fun bySemanticsLabel(label: Pattern): FlutterElement {
val f = _bySemanticsLabel(label)
f.setParent(driver)
return f
Expand Down Expand Up @@ -55,8 +62,13 @@ public class FlutterFinder(driver: RemoteWebDriver) {
f.setParent(driver)
return f
}
fun pageback(): FlutterElement {
val f = _pageback()
fun descendant(of: FlutterElement, matching: FlutterElement): FlutterElement {
val f = _descendant(of, matching)
f.setParent(driver)
return f
}
fun pageBack(): FlutterElement {
val f = _pageBack()
f.setParent(driver)
return f
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,8 @@
@file:JvmMultifileClass
package pro.truongsinh.appium_flutter.finder

import java.util.regex.Pattern;

fun bySemanticsLabel(label: String): FlutterElement {
return FlutterElement(mapOf(
"finderType" to "BySemanticsLabel",
Expand All @@ -10,7 +12,7 @@ fun bySemanticsLabel(label: String): FlutterElement {
))
}

fun bySemanticsLabel(label: Regex): FlutterElement {
fun bySemanticsLabel(label: Pattern): FlutterElement {
return FlutterElement(mapOf(
"finderType" to "BySemanticsLabel",
"isRegExp" to true,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,6 @@
@file:JvmMultifileClass
package pro.truongsinh.appium_flutter.finder

fun pageback(): FlutterElement {
fun pageBack(): FlutterElement {
return FlutterElement(mapOf("finderType" to "PageBack"))
}
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
package pro.truongsinh.appium_flutter.finder

import java.util.regex.Pattern;

import org.junit.Assert.assertEquals
import org.junit.Test

Expand All @@ -8,12 +10,12 @@ class FinderTest {
val expected = "eyJmaW5kZXJUeXBlIjoiQW5jZXN0b3IiLCJtYXRjaFJvb3QiOmZhbHNlLCJvZl9maW5kZXJUeXBlIjoiQW5jZXN0b3IiLCJvZl9tYXRjaFJvb3QiOmZhbHNlLCJvZl9vZl9maW5kZXJUeXBlIjoiUGFnZUJhY2siLCJvZl9tYXRjaGluZ19maW5kZXJUeXBlIjoiUGFnZUJhY2siLCJtYXRjaGluZ19maW5kZXJUeXBlIjoiQW5jZXN0b3IiLCJtYXRjaGluZ19tYXRjaFJvb3QiOmZhbHNlLCJtYXRjaGluZ19vZl9maW5kZXJUeXBlIjoiUGFnZUJhY2siLCJtYXRjaGluZ19tYXRjaGluZ19maW5kZXJUeXBlIjoiUGFnZUJhY2sifQ"
val observed = ancestor(
of = ancestor(
of = pageback(),
matching = pageback()
of = pageBack(),
matching = pageBack()
),
matching = ancestor(
of = pageback(),
matching = pageback()
of = pageBack(),
matching = pageBack()
)
).id
assertEquals(expected, observed)
Expand All @@ -22,7 +24,7 @@ class FinderTest {
assertEquals("eyJmaW5kZXJUeXBlIjoiQnlTZW1hbnRpY3NMYWJlbCIsImlzUmVnRXhwIjpmYWxzZSwibGFiZWwiOiJzaW1wbGUifQ", bySemanticsLabel("simple").id)
}
@Test fun TestBySemanticsLabelRegex() {
assertEquals("eyJmaW5kZXJUeXBlIjoiQnlTZW1hbnRpY3NMYWJlbCIsImlzUmVnRXhwIjp0cnVlLCJsYWJlbCI6ImNvbXBsaWNhdGVkIn0", bySemanticsLabel(Regex("complicated")).id)
assertEquals("eyJmaW5kZXJUeXBlIjoiQnlTZW1hbnRpY3NMYWJlbCIsImlzUmVnRXhwIjp0cnVlLCJsYWJlbCI6ImNvbXBsaWNhdGVkIn0", bySemanticsLabel(Pattern.compile("complicated")).id)
}
@Test fun TestByTooltip() {
assertEquals("eyJmaW5kZXJUeXBlIjoiQnlUb29sdGlwTWVzc2FnZSIsInRleHQiOiJteVRleHQifQ", byTooltip("myText").id)
Expand All @@ -44,18 +46,18 @@ class FinderTest {
val expected = "eyJmaW5kZXJUeXBlIjoiRGVzY2VuZGFudCIsIm1hdGNoUm9vdCI6ZmFsc2UsIm9mX2ZpbmRlclR5cGUiOiJEZXNjZW5kYW50Iiwib2ZfbWF0Y2hSb290IjpmYWxzZSwib2Zfb2ZfZmluZGVyVHlwZSI6IlBhZ2VCYWNrIiwib2ZfbWF0Y2hpbmdfZmluZGVyVHlwZSI6IlBhZ2VCYWNrIiwibWF0Y2hpbmdfZmluZGVyVHlwZSI6IkRlc2NlbmRhbnQiLCJtYXRjaGluZ19tYXRjaFJvb3QiOmZhbHNlLCJtYXRjaGluZ19vZl9maW5kZXJUeXBlIjoiUGFnZUJhY2siLCJtYXRjaGluZ19tYXRjaGluZ19maW5kZXJUeXBlIjoiUGFnZUJhY2sifQ"
val observed = descendant(
of = descendant(
of = pageback(),
matching = pageback()
of = pageBack(),
matching = pageBack()
),
matching = descendant(
of = pageback(),
matching = pageback()
of = pageBack(),
matching = pageBack()
)
).id
assertEquals(expected, observed)
}
@Test fun testPageback() {
assertEquals("eyJmaW5kZXJUeXBlIjoiUGFnZUJhY2sifQ", pageback().id)
assertEquals("eyJmaW5kZXJUeXBlIjoiUGFnZUJhY2sifQ", pageBack().id)
}
@Test fun testText() {
assertEquals("eyJmaW5kZXJUeXBlIjoiQnlUZXh0IiwidGV4dCI6IlRoaXMgaXMgMm5kIHJvdXRlIn0", text("This is 2nd route").id)
Expand Down

0 comments on commit 31c7c8a

Please sign in to comment.