Skip to content

Commit 7307777

Browse files
The addition to #738
- following dependencies were updated: `org.seleniumhq.selenium:selenium-java` to 3.6.0 `com.google.code.gson:gson` to 2.8.2 `org.springframework:spring-context` to 5.0.0.RELEASE `org.aspectj:aspectjweaver` to 1.8.11 - unused parameters and fields were removed from AppiumElementLocator, AppiumElementLocatorFactory - some test improving
1 parent a971cc8 commit 7307777

15 files changed

+191
-195
lines changed

build.gradle

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ apply plugin: 'signing'
88
apply plugin: 'maven-publish'
99

1010
group 'io.appium'
11-
version '5.0.3'
11+
version '5.0.4'
1212

1313
repositories {
1414
jcenter()
@@ -54,7 +54,7 @@ compileJava {
5454
]
5555
}
5656

57-
ext.seleniumVersion = '3.5.3'
57+
ext.seleniumVersion = '3.6.0'
5858

5959
dependencies {
6060
compile ("org.seleniumhq.selenium:selenium-java:${seleniumVersion}") {
@@ -73,14 +73,14 @@ dependencies {
7373
compile ("org.seleniumhq.selenium:selenium-api:${seleniumVersion}") {
7474
force = true
7575
}
76-
compile 'com.google.code.gson:gson:2.8.1'
76+
compile 'com.google.code.gson:gson:2.8.2'
7777
compile 'org.apache.httpcomponents:httpclient:4.5.3'
7878
compile 'cglib:cglib:3.2.5'
7979
compile 'commons-validator:commons-validator:1.6'
8080
compile 'org.apache.commons:commons-lang3:3.6'
8181
compile 'commons-io:commons-io:2.5'
82-
compile 'org.springframework:spring-context:4.3.10.RELEASE'
83-
compile 'org.aspectj:aspectjweaver:1.8.10'
82+
compile 'org.springframework:spring-context:5.0.0.RELEASE'
83+
compile 'org.aspectj:aspectjweaver:1.8.11'
8484
compile 'org.openpnp:opencv:3.2.0-1'
8585

8686
testCompile 'junit:junit:4.12'

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

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,9 @@
1616

1717
package io.appium.java_client.ios;
1818

19+
import static com.google.common.base.Preconditions.checkNotNull;
20+
import static io.appium.java_client.MobileCommand.pushFileCommand;
21+
1922
import io.appium.java_client.CommandExecutionHelper;
2023
import io.appium.java_client.ExecutesMethod;
2124
import org.apache.commons.codec.binary.Base64;
@@ -24,9 +27,6 @@
2427
import java.io.File;
2528
import java.io.IOException;
2629

27-
import static com.google.common.base.Preconditions.checkNotNull;
28-
import static io.appium.java_client.MobileCommand.pushFileCommand;
29-
3030
public interface PushesFiles extends ExecutesMethod {
3131

3232
/**

src/main/java/io/appium/java_client/pagefactory/AppiumElementLocator.java

Lines changed: 1 addition & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,6 @@
3535

3636
import java.util.ArrayList;
3737
import java.util.List;
38-
import java.util.concurrent.TimeUnit;
3938
import java.util.function.Function;
4039
import java.util.function.Supplier;
4140

@@ -45,7 +44,6 @@ class AppiumElementLocator implements CacheableLocator {
4544
private final By by;
4645
private final TimeOutDuration timeOutDuration;
4746
private final TimeOutDuration originalTimeOutDuration;
48-
private final WebDriver originalWebDriver;
4947
private final SearchContext searchContext;
5048
private WebElement cachedElement;
5149
private List<WebElement> cachedElementList;
@@ -61,18 +59,15 @@ class AppiumElementLocator implements CacheableLocator {
6159
* are found once should be cached
6260
* @param duration is a POJO which contains timeout parameters for the element to be searched
6361
* @param originalDuration is a POJO which contains timeout parameters from page object which contains the element
64-
* @param originalWebDriver is an instance of WebDriver that is going to be
65-
* used by a proxied element
6662
*/
6763

6864
public AppiumElementLocator(SearchContext searchContext, By by, boolean shouldCache,
69-
TimeOutDuration duration, TimeOutDuration originalDuration, WebDriver originalWebDriver) {
65+
TimeOutDuration duration, TimeOutDuration originalDuration) {
7066
this.searchContext = searchContext;
7167
this.shouldCache = shouldCache;
7268
this.timeOutDuration = duration;
7369
this.originalTimeOutDuration = originalDuration;
7470
this.by = by;
75-
this.originalWebDriver = originalWebDriver;
7671
this.exceptionMessageIfElementNotFound = "Can't locate an element by this strategy: " + by.toString();
7772
}
7873

src/main/java/io/appium/java_client/pagefactory/AppiumElementLocatorFactory.java

Lines changed: 2 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -21,30 +21,26 @@
2121
import io.appium.java_client.pagefactory.locator.CacheableLocator;
2222
import org.openqa.selenium.By;
2323
import org.openqa.selenium.SearchContext;
24-
import org.openqa.selenium.WebDriver;
2524

2625
import java.lang.reflect.AnnotatedElement;
2726
import java.lang.reflect.Field;
2827

2928
public class AppiumElementLocatorFactory implements CacheableElementLocatorFactory {
3029
private final SearchContext searchContext;
3130
private final TimeOutDuration timeOutDuration;
32-
private final WebDriver originalWebDriver;
3331
private final AppiumByBuilder builder;
3432

3533
/**
3634
* Creates a new mobile element locator factory.
3735
*
3836
* @param searchContext The context to use when finding the element
3937
* @param timeOutDuration is a POJO which contains timeout parameters for the element to be searched
40-
* @param originalWebDriver is an instance of WebDriver that is going to be used by a proxied element
4138
* @param builder is handler of Appium-specific page object annotations
4239
*/
4340

4441
public AppiumElementLocatorFactory(SearchContext searchContext, TimeOutDuration timeOutDuration,
45-
WebDriver originalWebDriver, AppiumByBuilder builder) {
42+
AppiumByBuilder builder) {
4643
this.searchContext = searchContext;
47-
this.originalWebDriver = originalWebDriver;
4844
this.timeOutDuration = timeOutDuration;
4945
this.builder = builder;
5046
}
@@ -66,7 +62,7 @@ public CacheableLocator createLocator(Field field) {
6662
By by = builder.buildBy();
6763
if (by != null) {
6864
return new AppiumElementLocator(searchContext, by, builder.isLookupCached(),
69-
customDuration, timeOutDuration, originalWebDriver);
65+
customDuration, timeOutDuration);
7066
}
7167
return null;
7268
}

src/main/java/io/appium/java_client/pagefactory/AppiumFieldDecorator.java

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -102,7 +102,7 @@ public AppiumFieldDecorator(SearchContext context, TimeOutDuration timeOutDurati
102102
this.timeOutDuration = timeOutDuration;
103103

104104
defaultElementFieldDecoracor = new DefaultFieldDecorator(
105-
new AppiumElementLocatorFactory(context, timeOutDuration, originalDriver,
105+
new AppiumElementLocatorFactory(context, timeOutDuration,
106106
new DefaultElementByBuilder(platform, automation))) {
107107
@Override
108108
protected WebElement proxyForLocator(ClassLoader ignored, ElementLocator locator) {
@@ -139,8 +139,7 @@ protected List<WebElement> proxyForListLocator(ClassLoader ignored,
139139
};
140140

141141
widgetLocatorFactory =
142-
new AppiumElementLocatorFactory(context, timeOutDuration, originalDriver,
143-
new WidgetByBuilder(platform, automation));
142+
new AppiumElementLocatorFactory(context, timeOutDuration, new WidgetByBuilder(platform, automation));
144143
}
145144

146145
public AppiumFieldDecorator(SearchContext context) {
Lines changed: 34 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,34 @@
1+
package io.appium.java_client;
2+
3+
import static java.nio.file.FileSystems.getDefault;
4+
import static org.openqa.selenium.Platform.MAC;
5+
import static org.openqa.selenium.Platform.WINDOWS;
6+
import static org.openqa.selenium.Platform.getCurrent;
7+
8+
import org.openqa.selenium.Platform;
9+
10+
import java.io.File;
11+
import java.nio.file.Path;
12+
13+
public final class ChromeDriverPathUtil {
14+
private static final Path ROOT_TEST_PATH = getDefault().getPath("src")
15+
.resolve("test").resolve("java").resolve("io").resolve("appium").resolve("java_client");
16+
17+
/**
18+
* @return the choromedriver file which depends on platform.
19+
*/
20+
public static File getChromeDriver() {
21+
Path resultPath;
22+
Platform current = getCurrent();
23+
24+
if (current.is(WINDOWS)) {
25+
resultPath = ROOT_TEST_PATH.resolve("chromedriver.exe");
26+
} else if (current.is(MAC)) {
27+
resultPath = ROOT_TEST_PATH.resolve("chromedriver_mac");
28+
} else {
29+
resultPath = ROOT_TEST_PATH.resolve("chromedriver_linux");
30+
}
31+
32+
return resultPath.toFile();
33+
}
34+
}
8.5 MB
Binary file not shown.

src/test/java/io/appium/java_client/pagefactory_tests/chromedriver renamed to src/test/java/io/appium/java_client/chromedriver_mac

10.3 MB
Binary file not shown.

src/test/java/io/appium/java_client/pagefactory_tests/DesktopBrowserCompatibilityTest.java

Lines changed: 4 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,9 @@
1616

1717
package io.appium.java_client.pagefactory_tests;
1818

19+
import static io.appium.java_client.ChromeDriverPathUtil.getChromeDriver;
1920
import static io.appium.java_client.pagefactory.LocatorGroupStrategy.ALL_POSSIBLE;
21+
import static java.lang.System.setProperty;
2022
import static org.junit.Assert.assertEquals;
2123
import static org.junit.Assert.assertNotEquals;
2224

@@ -27,7 +29,6 @@
2729
import io.appium.java_client.pagefactory.iOSFindBy;
2830
import org.junit.BeforeClass;
2931
import org.junit.Test;
30-
import org.openqa.selenium.Platform;
3132
import org.openqa.selenium.WebDriver;
3233
import org.openqa.selenium.WebElement;
3334
import org.openqa.selenium.chrome.ChromeDriver;
@@ -42,8 +43,6 @@
4243

4344
public class DesktopBrowserCompatibilityTest {
4445

45-
46-
private static final Platform current = Platform.getCurrent();
4746
@HowToUseLocators(iOSAutomation = ALL_POSSIBLE)
4847
@AndroidFindBy(className = "someClass")
4948
@iOSFindBy(xpath = "//selector[1]") @iOSFindBy(xpath = "//someTag")
@@ -57,13 +56,8 @@ public class DesktopBrowserCompatibilityTest {
5756
* The starting.
5857
*/
5958
@BeforeClass public static void beforeClass() {
60-
if (current.is(Platform.WINDOWS)) {
61-
System.setProperty(ChromeDriverService.CHROME_DRIVER_EXE_PROPERTY,
62-
"src/test/java/io/appium/java_client/pagefactory_tests/chromedriver.exe");
63-
} else {
64-
System.setProperty(ChromeDriverService.CHROME_DRIVER_EXE_PROPERTY,
65-
"src/test/java/io/appium/java_client/pagefactory_tests/chromedriver");
66-
}
59+
setProperty(ChromeDriverService.CHROME_DRIVER_EXE_PROPERTY,
60+
getChromeDriver().getAbsolutePath());
6761
}
6862

6963
@Test public void chromeTest() {

src/test/java/io/appium/java_client/pagefactory_tests/MobileBrowserCompatibilityTest.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -44,7 +44,7 @@ public class MobileBrowserCompatibilityTest {
4444
private AppiumDriverLocalService service;
4545

4646
@AndroidFindBy(className = "someClass") @AndroidFindBy(xpath = "//someTag")
47-
private RemoteWebElement btnG; //this element should be found by id = 'btnG' or name = 'btnG'
47+
private RemoteWebElement btnK; //this element should be found by id = 'btnG' or name = 'btnG'
4848

4949
@FindBy(name = "q")
5050
@AndroidFindBy(uiAutomator = "new UiSelector().resourceId(\"android:id/someId\")")
@@ -87,7 +87,7 @@ public class MobileBrowserCompatibilityTest {
8787
driver.get("https://www.google.com");
8888

8989
searchTextField.sendKeys("Hello");
90-
btnG.click();
90+
btnK.click();
9191
Assert.assertNotEquals(0, foundLinks.size());
9292
}
9393

0 commit comments

Comments
 (0)