Skip to content

Commit 88197f7

Browse files
committed
removed scrollTo() from AndroidElement
1 parent 6a5dcf4 commit 88197f7

File tree

5 files changed

+20
-48
lines changed

5 files changed

+20
-48
lines changed

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

+1-1
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,7 @@
2727

2828
import java.util.List;
2929

30-
public abstract class MobileElement extends RemoteWebElement implements FindsByAccessibilityId, ScrollsTo {
30+
public abstract class MobileElement extends RemoteWebElement implements FindsByAccessibilityId {
3131

3232
protected FileDetector fileDetector;
3333

src/main/java/io/appium/java_client/android/AndroidElement.java

-23
Original file line numberDiff line numberDiff line change
@@ -20,27 +20,4 @@ public List<WebElement> findElementsByAndroidUIAutomator(String using) {
2020
return findElements("-android uiautomator", using);
2121
}
2222

23-
/**
24-
* Scroll forward to the element which has a description or name which contains the input text.
25-
* The scrolling is performed on the first scrollView present on the UI
26-
* @param text
27-
*/
28-
@Override
29-
public MobileElement scrollTo(String text) {
30-
String uiScrollables = AndroidDriver.UiScrollable("new UiSelector().descriptionContains(\"" + text + "\")") +
31-
AndroidDriver.UiScrollable("new UiSelector().textContains(\"" + text + "\")");
32-
return (MobileElement) findElementByAndroidUIAutomator(uiScrollables);
33-
}
34-
35-
/**
36-
* Scroll forward to the element which has a description or name which exactly matches the input text.
37-
* The scrolling is performed on the first scrollView present on the UI
38-
* @param text
39-
*/
40-
@Override
41-
public MobileElement scrollToExact(String text) {
42-
String uiScrollables = AndroidDriver.UiScrollable("new UiSelector().description(\"" + text + "\")") +
43-
AndroidDriver.UiScrollable("new UiSelector().text(\"" + text + "\")");
44-
return (MobileElement) findElementByAndroidUIAutomator(uiScrollables);
45-
}
4623
}

src/main/java/io/appium/java_client/ios/IOSDriver.java

+4-4
Original file line numberDiff line numberDiff line change
@@ -27,22 +27,22 @@ public IOSDriver(URL remoteAddress, Capabilities desiredCapabilities) {
2727

2828
/**
2929
* Scroll to the element whose 'text' attribute contains the input text.
30-
* This scrolling happens within the first UIATableView on the UI. Use the additional 'context' param to specify a different scrollView.
30+
* This scrolling happens within the first UIATableView on the UI. Use the method on IOSElement to scroll from a different ScrollView.
3131
* @param text input text contained in text attribute
3232
*/
3333
@Override
3434
public MobileElement scrollTo(String text) {
35-
return ((MobileElement) findElementByClassName("UIATableView")).scrollTo(text);
35+
return ((IOSElement) findElementByClassName("UIATableView")).scrollTo(text);
3636
}
3737

3838
/**
3939
* Scroll to the element whose 'text' attribute is equal to the input text.
40-
* This scrolling happens within the first UIATableView on the UI. Use the additional 'context' param to specify a different scrollView.
40+
* This scrolling happens within the first UIATableView on the UI. Use the method on IOSElement to scroll from a different ScrollView.
4141
* @param text input text to match
4242
*/
4343
@Override
4444
public MobileElement scrollToExact(String text) {
45-
return ((MobileElement) findElementByClassName("UIATableView")).scrollToExact(text);
45+
return ((IOSElement) findElementByClassName("UIATableView")).scrollToExact(text);
4646
}
4747

4848
/**

src/main/java/io/appium/java_client/ios/IOSElement.java

+15-5
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,13 @@
11
package io.appium.java_client.ios;
22

3-
import java.util.List;
4-
5-
import org.openqa.selenium.WebElement;
6-
73
import io.appium.java_client.FindsByIosUIAutomation;
84
import io.appium.java_client.MobileElement;
5+
import io.appium.java_client.ScrollsTo;
6+
import org.openqa.selenium.WebElement;
7+
8+
import java.util.List;
99

10-
public class IOSElement extends MobileElement implements FindsByIosUIAutomation{
10+
public class IOSElement extends MobileElement implements FindsByIosUIAutomation, ScrollsTo {
1111

1212
@Override
1313
public WebElement findElementByIosUIAutomation(String using) {
@@ -19,11 +19,21 @@ public List<WebElement> findElementsByIosUIAutomation(String using) {
1919
return findElements("-ios uiautomation", using);
2020
}
2121

22+
/**
23+
* Scroll to the element whose 'text' attribute contains the input text.
24+
* Scrolling happens within this element
25+
* @param text input text contained in text attribute
26+
*/
2227
@Override
2328
public MobileElement scrollTo(String text) {
2429
return (MobileElement) findElementByIosUIAutomation(".scrollToElementWithPredicate(\"name CONTAINS '" + text + "'\")");
2530
}
2631

32+
/**
33+
* Scroll to the element whose 'text' attribute matches the input text.
34+
* Scrolling happens within this element
35+
* @param text input text contained in text attribute
36+
*/
2737
@Override
2838
public MobileElement scrollToExact(String text) {
2939
return (MobileElement) findElementByIosUIAutomation(".scrollToElementWithName(\"" + text + "\")");

src/test/java/io/appium/java_client/android/AndroidDriverTest.java

-15
Original file line numberDiff line numberDiff line change
@@ -18,15 +18,12 @@
1818
package io.appium.java_client.android;
1919

2020
import io.appium.java_client.AppiumSetting;
21-
import io.appium.java_client.MobileElement;
2221
import io.appium.java_client.NetworkConnectionSetting;
2322
import io.appium.java_client.remote.MobileCapabilityType;
24-
2523
import org.apache.commons.codec.binary.Base64;
2624
import org.junit.After;
2725
import org.junit.Before;
2826
import org.junit.Test;
29-
import org.openqa.selenium.By;
3027
import org.openqa.selenium.WebElement;
3128
import org.openqa.selenium.remote.DesiredCapabilities;
3229

@@ -172,16 +169,4 @@ public void scrollToExactTest() {
172169
WebElement views = driver.findElementByAccessibilityId("Views");
173170
assertNotNull(views);
174171
}
175-
176-
@Test
177-
public void scrollToFromElementTest() {
178-
MobileElement el = ((MobileElement) (driver.findElement(By.className("android.widget.FrameLayout")))).scrollTo("View");
179-
assertNotNull(el);
180-
}
181-
182-
@Test
183-
public void scrollToExactFromElementTest() {
184-
MobileElement el = ((MobileElement) (driver.findElement(By.className("android.widget.FrameLayout")))).scrollToExact("Views");
185-
assertNotNull(el);
186-
}
187172
}

0 commit comments

Comments
 (0)