Skip to content

Commit 7915c15

Browse files
Replace GSON with native JSON serializer
1 parent 521ef10 commit 7915c15

File tree

2 files changed

+35
-2
lines changed

2 files changed

+35
-2
lines changed

src/e2eFlutterTest/java/io/appium/java_client/android/CommandTest.java

Lines changed: 32 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -160,4 +160,36 @@ void testCameraMocking() throws IOException {
160160
driver.findElement(AppiumBy.flutterText("PICK")).click();
161161
assertTrue(driver.findElement(AppiumBy.flutterText("Success!")).isDisplayed());
162162
}
163+
164+
@Test
165+
void testScrollTillVisibleForAncestor() {
166+
WebElement loginButton = driver.findElement(BaseFlutterTest.LOGIN_BUTTON);
167+
loginButton.click();
168+
openScreen("Nested Scroll");
169+
170+
AppiumBy.FlutterBy ancestorBy = AppiumBy.flutterAncestor(
171+
AppiumBy.flutterText("Child 2"),
172+
AppiumBy.flutterKey("parent_card_4")
173+
);
174+
175+
assertEquals(0, driver.findElements(ancestorBy).size());
176+
driver.scrollTillVisible(new ScrollParameter(ancestorBy));
177+
assertEquals(1, driver.findElements(ancestorBy).size());
178+
}
179+
180+
@Test
181+
void testScrollTillVisibleForDescendant() {
182+
WebElement loginButton = driver.findElement(BaseFlutterTest.LOGIN_BUTTON);
183+
loginButton.click();
184+
openScreen("Nested Scroll");
185+
186+
AppiumBy.FlutterBy descendantBy = AppiumBy.flutterDescendant(
187+
AppiumBy.flutterKey("parent_card_4"),
188+
AppiumBy.flutterText("Child 2")
189+
);
190+
191+
assertEquals(0, driver.findElements(descendantBy).size());
192+
driver.scrollTillVisible(new ScrollParameter(descendantBy));
193+
assertEquals(1, driver.findElements(descendantBy).size());
194+
}
163195
}

src/main/java/io/appium/java_client/AppiumBy.java

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,7 @@
2424
import org.openqa.selenium.By.Remotable;
2525
import org.openqa.selenium.SearchContext;
2626
import org.openqa.selenium.WebElement;
27+
import org.openqa.selenium.json.Json;
2728

2829
import java.io.Serializable;
2930
import java.util.HashMap;
@@ -383,7 +384,7 @@ protected FlutterBy(String selector, String locatorString, String locatorName) {
383384
}
384385

385386
public abstract static class FlutterByHierarchy extends FlutterBy {
386-
private static final Gson GSON = new Gson();
387+
private static final Json json = new Json();
387388

388389
protected FlutterByHierarchy(
389390
String selector,
@@ -404,7 +405,7 @@ static String formatLocator(FlutterBy of, FlutterBy matching, Map<String, Object
404405
locator.put("of", parseFlutterLocator(of));
405406
locator.put("matching", parseFlutterLocator(matching));
406407
locator.put("parameters", properties);
407-
return GSON.toJson(locator);
408+
return json.toJson(locator);
408409
}
409410
}
410411

0 commit comments

Comments
 (0)