Skip to content

Commit 85bc560

Browse files
committed
parity example with NodeJS
1 parent 19a4e1f commit 85bc560

File tree

1 file changed

+49
-4
lines changed

1 file changed

+49
-4
lines changed

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

Lines changed: 49 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@
1111

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

1717
public class FlutterTest extends BaseDriver {
@@ -25,7 +25,8 @@ public void setUp() throws Exception {
2525
public void basicTest () throws InterruptedException {
2626
MobileElement counterTextFinder = find.byValueKey("counter");
2727
MobileElement buttonFinder = find.byValueKey("increment");
28-
// await validateElementPosition(driver, buttonFinder);
28+
29+
validateElementPosition(buttonFinder);
2930

3031
assertEquals(driver.executeScript("flutter:checkHealth"), "ok");
3132
driver.executeScript("flutter:clearTimeline");
@@ -92,9 +93,53 @@ public void basicTest () throws InterruptedException {
9293
put("frequency", 30);
9394
}});
9495

95-
/*
96-
*/
96+
driver.executeScript("flutter:scrollIntoView", find.byType("ListView"), new HashMap<String, Object>() {{
97+
put("alignment", 0.1);
98+
}});
9799

100+
find.byType("TextField").click(); // acquire focus
101+
driver.executeScript("flutter:enterText", "I can enter text"); // enter text
102+
driver.executeScript("flutter:waitFor", find.text("I can enter text")); // verify text appears on UI
103+
104+
// @todo should be `pageBack`
105+
find.pageback().click();
106+
driver.executeScript("flutter:waitFor", buttonFinder);
107+
108+
find.descendant(
109+
find.ancestor(
110+
// @todo should be Java Pattern
111+
find.bySemanticsLabel(new Regex("counter_semantic")),
112+
find.byType("Tooltip"),
113+
false
114+
),
115+
find.byType("Text"),
116+
false
117+
)
118+
.click()
119+
;
120+
121+
driver.quit();
98122
}
99123

124+
private void validateElementPosition(MobileElement buttonFinder) {
125+
Map bottomLeft = (Map) driver.executeScript("flutter:getBottomLeft", buttonFinder);
126+
assertEquals(bottomLeft.get("dx") instanceof Long, true);
127+
assertEquals(bottomLeft.get("dy") instanceof Long, true);
128+
129+
Map bottomRight = (Map) driver.executeScript("flutter:getBottomRight", buttonFinder);
130+
assertEquals(bottomRight.get("dx") instanceof Long, true);
131+
assertEquals(bottomRight.get("dy") instanceof Long, true);
132+
133+
Map center = (Map) driver.executeScript("flutter:getCenter", buttonFinder);
134+
assertEquals(center.get("dx") instanceof Long, true);
135+
assertEquals(center.get("dy") instanceof Long, true);
136+
137+
Map topLeft = (Map) driver.executeScript("flutter:getTopLeft", buttonFinder);
138+
assertEquals(topLeft.get("dx") instanceof Long, true);
139+
assertEquals(topLeft.get("dy") instanceof Long, true);
140+
141+
Map topRight = (Map) driver.executeScript("flutter:getTopRight", buttonFinder);
142+
assertEquals(topRight.get("dx") instanceof Long, true);
143+
assertEquals(topRight.get("dy") instanceof Long, true);
144+
}
100145
}

0 commit comments

Comments
 (0)