diff --git a/README.md b/README.md index 50d160ef0..c9bbe2ae4 100644 --- a/README.md +++ b/README.md @@ -60,8 +60,10 @@ Locators: - findElementsByAndroidUIAutomator() ##Changelog## -*github HEAD* +*1.3.0* - MultiGesture with a single TouchAction fixed for Android +- Now depends upon Selenium java client 2.42.1 +- Cleanup of Errorcode handling, due to merging a change into Selenium *1.2.1* - fix dependency issue diff --git a/java-client.iml b/java-client.iml index a4f227eca..43fb3c1cc 100644 --- a/java-client.iml +++ b/java-client.iml @@ -12,8 +12,6 @@ - - @@ -25,12 +23,12 @@ - - - + + + - + @@ -39,30 +37,30 @@ - - + + - - - + + + - - + + - - - - - - - - + + + + + + + + - + diff --git a/pom.xml b/pom.xml index 7b556ab5a..bcf8992ab 100644 --- a/pom.xml +++ b/pom.xml @@ -6,7 +6,7 @@ io.appium java-client - 1.2.1 + 1.3.0 com.google.collections @@ -21,7 +21,7 @@ org.seleniumhq.selenium selenium-java - 2.41.0 + 2.42.1 junit diff --git a/src/main/java/io/appium/java_client/AppiumDriver.java b/src/main/java/io/appium/java_client/AppiumDriver.java index b1ec52ec8..101f8521a 100644 --- a/src/main/java/io/appium/java_client/AppiumDriver.java +++ b/src/main/java/io/appium/java_client/AppiumDriver.java @@ -34,7 +34,7 @@ public class AppiumDriver extends RemoteWebDriver implements MobileDriver, ContextAware, Rotatable, FindsByIosUIAutomation, FindsByAndroidUIAutomator, FindsByAccessibilityId { - private final static MobileErrorHandler errorHandler = new MobileErrorHandler(); + private final static ErrorHandler errorHandler = new ErrorHandler(new ErrorCodesMobile(), true); private URL remoteAddress; private ComplexFind complexFind; @@ -73,18 +73,13 @@ public AppiumDriver(URL remoteAddress, Capabilities desiredCapabilities){ HttpCommandExecutor mobileExecutor = new HttpCommandExecutor(mobileCommands, remoteAddress); super.setCommandExecutor(mobileExecutor); + super.setErrorHandler(errorHandler); } @Override public Response execute(String driverCommand, Map parameters) { - try { - return super.execute(driverCommand, parameters); - } catch (WebDriverException ex) { - errorHandler.throwIfMobileError(ex); - } - throw new RuntimeException("An WebDriver error should have been thrown, if you're reading this, the problem is " + - "definitely in the Appium Driver"); + return super.execute(driverCommand, parameters); } @Override diff --git a/src/main/java/io/appium/java_client/MobileErrorHandler.java b/src/main/java/io/appium/java_client/MobileErrorHandler.java deleted file mode 100644 index efdd7d5da..000000000 --- a/src/main/java/io/appium/java_client/MobileErrorHandler.java +++ /dev/null @@ -1,83 +0,0 @@ -/* - +Copyright 2014 Appium contributors - +Copyright 2014 Software Freedom Conservancy - + - +Licensed under the Apache License, Version 2.0 (the "License"); - +you may not use this file except in compliance with the License. - +You may obtain a copy of the License at - + - + http://www.apache.org/licenses/LICENSE-2.0 - + - +Unless required by applicable law or agreed to in writing, software - +distributed under the License is distributed on an "AS IS" BASIS, - +WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - +See the License for the specific language governing permissions and - +limitations under the License. - + */ - -package io.appium.java_client; - -import org.openqa.selenium.WebDriverException; - -import java.lang.reflect.Constructor; -import java.lang.reflect.InvocationTargetException; - -/** - * Created by jonahss on 4/8/14. - */ -public class MobileErrorHandler { - - private final ErrorCodesMobile errorCodes = new ErrorCodesMobile(); - - public void throwIfMobileError(WebDriverException originalException) throws RuntimeException { - - Class mobileErrorType = - errorCodes.getExceptionType(originalException.getMessage()); - - if (mobileErrorType == null) { - throw originalException; - } - - - WebDriverException toThrow = null; - - if (toThrow == null) { - toThrow = createThrowable(mobileErrorType, - new Class[]{String.class, Throwable.class}, - new Object[]{originalException.getMessage(), originalException.getCause()}); - } - - if (toThrow == null) { - toThrow = createThrowable(mobileErrorType, - new Class[]{String.class}, - new Object[]{originalException.getMessage()}); - } - - if (toThrow == null) { - toThrow = originalException; - } - - throw toThrow; - - } - - private T createThrowable( - Class clazz, Class[] parameterTypes, Object[] parameters) { - try { - Constructor constructor = clazz.getConstructor(parameterTypes); - return constructor.newInstance(parameters); - } catch (NoSuchMethodException e) { - // Do nothing - fall through. - } catch (InvocationTargetException e) { - // Do nothing - fall through. - } catch (InstantiationException e) { - // Do nothing - fall through. - } catch (IllegalAccessException e) { - // Do nothing - fall through. - } catch (OutOfMemoryError error) { - // It can happen... - } - return null; - } - -}