diff --git a/build.gradle b/build.gradle index 26098d0a1..de9b92d1e 100644 --- a/build.gradle +++ b/build.gradle @@ -1,4 +1,5 @@ apply plugin: 'java' +apply plugin: 'idea' apply plugin: 'maven' apply plugin: 'eclipse' apply plugin: 'jacoco' @@ -7,7 +8,7 @@ apply plugin: 'signing' apply plugin: 'maven-publish' group 'io.appium' -version '5.0.0-BETA9' +version '5.0.0' repositories { jcenter() @@ -53,18 +54,28 @@ compileJava { ] } +ext.seleniumVersion = '3.5.+' + dependencies { - compile('org.seleniumhq.selenium:selenium-java:3.4.0'){ + compile ("org.seleniumhq.selenium:selenium-java:${seleniumVersion}") { + force = true + exclude module: 'cglib' exclude group: 'com.google.code.gson' } + compile ("org.seleniumhq.selenium:selenium-support:${seleniumVersion}") { + force = true + } + compile ("org.seleniumhq.selenium:selenium-api:${seleniumVersion}") { + force = true + } compile 'com.google.code.gson:gson:2.8.1' compile 'org.apache.httpcomponents:httpclient:4.5.3' compile 'cglib:cglib:3.2.5' compile 'commons-validator:commons-validator:1.6' - compile 'org.apache.commons:commons-lang3:3.5' + compile 'org.apache.commons:commons-lang3:3.6' compile 'commons-io:commons-io:2.5' - compile 'org.springframework:spring-context:4.3.8.RELEASE' + compile 'org.springframework:spring-context:4.3.10.RELEASE' compile 'org.aspectj:aspectjweaver:1.8.10' compile 'org.openpnp:opencv:3.2.0-1' diff --git a/src/main/java/io/appium/java_client/AppiumDriver.java b/src/main/java/io/appium/java_client/AppiumDriver.java index 0a51b5271..be4900a23 100644 --- a/src/main/java/io/appium/java_client/AppiumDriver.java +++ b/src/main/java/io/appium/java_client/AppiumDriver.java @@ -209,8 +209,12 @@ public List findElementsByXPath(String using) { @Override public WebDriver context(String name) { checkNotNull(name, "Must supply a context name"); - execute(DriverCommand.SWITCH_TO_CONTEXT, ImmutableMap.of("name", name)); - return this; + try { + execute(DriverCommand.SWITCH_TO_CONTEXT, ImmutableMap.of("name", name)); + return this; + } catch (WebDriverException e) { + throw new NoSuchContextException(e.getMessage(), e); + } } @Override public Set getContextHandles() { diff --git a/src/main/java/io/appium/java_client/internal/JsonToMobileElementConverter.java b/src/main/java/io/appium/java_client/internal/JsonToMobileElementConverter.java index 103963d14..923910e76 100644 --- a/src/main/java/io/appium/java_client/internal/JsonToMobileElementConverter.java +++ b/src/main/java/io/appium/java_client/internal/JsonToMobileElementConverter.java @@ -20,7 +20,6 @@ import com.google.common.collect.Iterables; import com.google.common.collect.Lists; -import com.google.common.collect.Maps; import io.appium.java_client.HasSessionDetails; import org.openqa.selenium.WebDriverException; @@ -30,7 +29,6 @@ import java.lang.reflect.Constructor; import java.util.Collection; -import java.util.Map; /** * Reconstitutes {@link org.openqa.selenium.WebElement}s from their JSON representation. Will recursively convert Lists @@ -63,16 +61,13 @@ public Object apply(Object result) { return Lists.newArrayList(Iterables.transform(results, this)); } - if (result instanceof Map) { - Map resultAsMap = (Map) result; - if (resultAsMap.containsKey("ELEMENT")) { - RemoteWebElement element = newMobileElement(); - element.setId(String.valueOf(resultAsMap.get("ELEMENT"))); - element.setFileDetector(driver.getFileDetector()); - return element; - } else { - return Maps.transformValues(resultAsMap, this); - } + if (result instanceof RemoteWebElement) { + RemoteWebElement resultElement = RemoteWebElement.class.cast(result); + RemoteWebElement element = newMobileElement(); + element.setParent(driver); + element.setId(resultElement.getId()); + element.setFileDetector(driver.getFileDetector()); + return element; } if (result instanceof Number) { diff --git a/src/main/java/io/appium/java_client/pagefactory/DefaultElementByBuilder.java b/src/main/java/io/appium/java_client/pagefactory/DefaultElementByBuilder.java index 84e815997..473a5188e 100644 --- a/src/main/java/io/appium/java_client/pagefactory/DefaultElementByBuilder.java +++ b/src/main/java/io/appium/java_client/pagefactory/DefaultElementByBuilder.java @@ -96,20 +96,20 @@ protected By buildDefaultBy() { By defaultBy = null; FindBy findBy = annotatedElement.getAnnotation(FindBy.class); if (findBy != null) { - defaultBy = super.buildByFromFindBy(findBy); + defaultBy = new FindBy.FindByBuilder().buildIt(findBy, (Field) annotatedElement); } if (defaultBy == null) { FindBys findBys = annotatedElement.getAnnotation(FindBys.class); if (findBys != null) { - defaultBy = super.buildByFromFindBys(findBys); + defaultBy = new FindBys.FindByBuilder().buildIt(findBys, (Field) annotatedElement); } } if (defaultBy == null) { FindAll findAll = annotatedElement.getAnnotation(FindAll.class); if (findAll != null) { - defaultBy = super.buildBysFromFindByOneOf(findAll); + defaultBy = new FindAll.FindByBuilder().buildIt(findAll, (Field) annotatedElement); } } return defaultBy;