Skip to content

Commit

Permalink
fix(kotlin): tweak ancestor/descendant (#717)
Browse files Browse the repository at this point in the history
* fix pom

* fix(kotlin): tweak ancestor/descendant
  • Loading branch information
KazuCocoa authored Jul 14, 2024
1 parent 0e91d62 commit c3e3be4
Show file tree
Hide file tree
Showing 4 changed files with 29 additions and 22 deletions.
32 changes: 14 additions & 18 deletions example/java/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -45,18 +45,17 @@
</dependency>

<dependency>
<groupId>io.appium</groupId>
<artifactId>java-client</artifactId>
<version>4.1.2</version>
</dependency>
<dependency>
<groupId>pro.truongsinh</groupId>
<artifactId>appium-flutter-finder</artifactId>
<version>0.0.4</version>
</dependency>
<groupId>io.appium</groupId>
<artifactId>java-client</artifactId>
<version>4.1.2</version>
</dependency>
<dependency>
<groupId>com.github.appium</groupId>
<artifactId>appium-flutter-driver</artifactId>
<version>main-SNAPSHOT</version>
</dependency>

</dependencies>

<build>
<plugins>
<plugin>
Expand Down Expand Up @@ -84,12 +83,9 @@
<enabled>true</enabled>
</snapshots>
</repository>

<repository>
<id>local-maven-repo</id>
<url>file:///Users/truongsinh/Dev/flutter/appium-flutter-driver/finder/kotlin/build/repository</url>
</repository>
</repositories>


<repository>
<id>jitpack.io</id>
<url>https://jitpack.io</url>
</repository>
</repositories>
</project>
9 changes: 5 additions & 4 deletions example/java/src/test/java/example/appium/FlutterTest.java
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@
import org.openqa.selenium.OutputType;
import io.appium.java_client.MobileElement;
import pro.truongsinh.appium_flutter.FlutterFinder;
import pro.truongsinh.appium_flutter.finder.FlutterElement;

public class FlutterTest extends BaseDriver {
protected FlutterFinder find;
Expand All @@ -25,7 +26,7 @@ public void setUp() throws Exception {
@Test
public void basicTest () throws InterruptedException {
String buttonFinderKey = "increment";
MobileElement counterTextFinder = find.byValueKey("counter");
FlutterElement counterTextFinder = find.byValueKey("counter");
MobileElement buttonFinder = waitFor(buttonFinderKey);

validateElementPosition(buttonFinder);
Expand Down Expand Up @@ -73,7 +74,7 @@ public void basicTest () throws InterruptedException {

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

assertEquals(find.descendant(find.byTooltip("counter_tooltip"), find.byValueKey("counter")).getText(), "3");
assertEquals(find.descendant(find.byTooltip("counter_tooltip"), find.byValueKey("counter"), false, false).getText(), "3");

find.byType("FlatButton").click();
driver.executeScript("flutter:waitForAbsent", buttonFinder);
Expand Down Expand Up @@ -107,9 +108,9 @@ public void basicTest () throws InterruptedException {
find.descendant(
find.ancestor(
find.bySemanticsLabel(Pattern.compile("counter_semantic")),
find.byType("Tooltip")
find.byType("Tooltip"), false, false
),
find.byType("Text")
find.byType("Text"), false, false
)
.click()
;
Expand Down
1 change: 1 addition & 0 deletions finder/kotlin/gradle.properties
Original file line number Diff line number Diff line change
Expand Up @@ -24,3 +24,4 @@ org.gradle.vfs.watch=true
org.gradle.caching=true
# https://youtrack.jetbrains.com/issue/KT-46708
kotlin.stdlib.default.dependency=false
kotlin.experimental=true
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,12 @@ import pro.truongsinh.appium_flutter.finder.text as _text

public class FlutterFinder(private val driver: RemoteWebDriver) {
private val fileDetector = FileDetector { _ -> null }
fun ancestor(of: FlutterElement, matching: FlutterElement): FlutterElement {
val f = _ancestor(of, matching, matchRoot = false, firstMatchOnly = false)
f.setParent(driver)
f.setFileDetector(fileDetector)
return f
}
fun ancestor(of: FlutterElement, matching: FlutterElement, matchRoot: Boolean = false, firstMatchOnly: Boolean = false): FlutterElement {
val f = _ancestor(of, matching, matchRoot, firstMatchOnly)
f.setParent(driver)
Expand Down Expand Up @@ -59,6 +65,9 @@ public class FlutterFinder(private val driver: RemoteWebDriver) {
f.setFileDetector(fileDetector)
return f
}
fun descendant(of: FlutterElement, matching: FlutterElement): FlutterElement {
return _descendant(of, matching, matchRoot = false, firstMatchOnly = false)
}
fun descendant(of: FlutterElement, matching: FlutterElement, matchRoot: Boolean = false, firstMatchOnly: Boolean = false): FlutterElement {
val f = _descendant(of, matching, matchRoot, firstMatchOnly)
f.setParent(driver)
Expand Down

0 comments on commit c3e3be4

Please sign in to comment.