Skip to content

Commit 168d9d8

Browse files
- test improvement
1 parent 6bdf9f7 commit 168d9d8

2 files changed

Lines changed: 13 additions & 22 deletions

File tree

Lines changed: 8 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,11 @@
11
package io.appium.java_client.android;
22

33
import static org.junit.Assert.assertNotEquals;
4+
import static org.openqa.selenium.By.id;
45

5-
import com.google.common.base.Function;
66

77
import org.junit.Test;
88

9-
import org.openqa.selenium.WebDriver;
109
import org.openqa.selenium.support.ui.WebDriverWait;
1110

1211
import java.util.List;
@@ -17,18 +16,15 @@ public void openNotification() throws Exception {
1716
driver.closeApp();
1817
driver.openNotifications();
1918
WebDriverWait wait = new WebDriverWait(driver, 20);
20-
assertNotEquals(0, wait.until(new Function<WebDriver, List<AndroidElement>>() {
21-
@Override
22-
public List<AndroidElement> apply(WebDriver input) {
23-
List<AndroidElement> result = driver
24-
.findElementsById("com.android.systemui:id/carrier_label");
19+
assertNotEquals(0, wait.until(input -> {
20+
List<AndroidElement> result = input
21+
.findElements(id("com.android.systemui:id/carrier_label"));
2522

26-
if (result.size() == 0) {
27-
return null;
28-
}
29-
30-
return result;
23+
if (result.size() == 0) {
24+
return null;
3125
}
26+
27+
return result;
3228
}).size());
3329
}
3430
}

src/test/java/io/appium/java_client/ios/IOSElementTest.java

Lines changed: 5 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -5,13 +5,11 @@
55
import static org.junit.Assert.assertEquals;
66
import static org.junit.Assert.assertThat;
77

8-
import com.google.common.base.Function;
98

109
import org.junit.FixMethodOrder;
1110
import org.junit.Test;
1211
import org.junit.runners.MethodSorters;
1312
import org.openqa.selenium.By;
14-
import org.openqa.selenium.WebDriver;
1513
import org.openqa.selenium.WebElement;
1614
import org.openqa.selenium.support.ui.WebDriverWait;
1715

@@ -32,15 +30,12 @@ public class IOSElementTest extends UICatalogIOSTest {
3230

3331
WebDriverWait wait = new WebDriverWait(driver, 20);
3432

35-
IOSElement slider = (IOSElement) wait.until(new Function<WebDriver, List<WebElement>>() {
36-
@Override
37-
public List<WebElement> apply(WebDriver input) {
38-
List<WebElement> result = input.findElements(By.className("UIASlider"));
39-
if (result.size() == 0) {
40-
return null;
41-
}
42-
return result;
33+
IOSElement slider = (IOSElement) wait.until(input -> {
34+
List<WebElement> result = input.findElements(By.className("UIASlider"));
35+
if (result.size() == 0) {
36+
return null;
4337
}
38+
return result;
4439
}).get(1);
4540
slider.setValue("0%");
4641
assertEquals("0%", slider.getAttribute("value"));

0 commit comments

Comments
 (0)