Selenium 3 updates by SrinivasanTarget · Pull Request #489 · appium/java-client

Expand Up @@ -30,6 +30,7 @@
import org.openqa.selenium.By; import org.openqa.selenium.Capabilities; import org.openqa.selenium.DeviceRotation; import org.openqa.selenium.Dimension; import org.openqa.selenium.Point; import org.openqa.selenium.ScreenOrientation; Expand Down Expand Up @@ -57,17 +58,18 @@ import java.util.Map; import java.util.Set;

/** * @param <T> the required type of class which implement {@link org.openqa.selenium.WebElement}. * Instances of the defined type will be returned via findElement* and findElements* * Warning (!!!). Allowed types: * {@link org.openqa.selenium.WebElement} * {@link io.appium.java_client.TouchableElement} * {@link org.openqa.selenium.remote.RemoteWebElement} * {@link io.appium.java_client.MobileElement} and its subclasses that designed * specifically * for each target mobile OS (still Android and iOS) */ * @param <T> the required type of class which implement {@link org.openqa.selenium.WebElement}. * Instances of the defined type will be returned via findElement* and findElements* * Warning (!!!). Allowed types: * {@link org.openqa.selenium.WebElement} * {@link io.appium.java_client.TouchableElement} * {@link org.openqa.selenium.remote.RemoteWebElement} * {@link io.appium.java_client.MobileElement} and its subclasses that designed * specifically * for each target mobile OS (still Android and iOS) */ @SuppressWarnings("unchecked") public abstract class AppiumDriver<T extends WebElement> extends DefaultGenericMobileDriver<T> { Expand All @@ -79,13 +81,13 @@ public abstract class AppiumDriver<T extends WebElement> private ExecuteMethod executeMethod;
/** * @param executor is an instance of {@link org.openqa.selenium.remote.HttpCommandExecutor} * or class that extends it. Default commands or another vendor-specific * commands may be specified there. * @param capabilities take a look * at {@link org.openqa.selenium.Capabilities} * @param executor is an instance of {@link org.openqa.selenium.remote.HttpCommandExecutor} * or class that extends it. Default commands or another vendor-specific * commands may be specified there. * @param capabilities take a look * at {@link org.openqa.selenium.Capabilities} * @param converterClazz is an instance of a class that extends * {@link org.openqa.selenium.remote.internal.JsonToWebElementConverter}. It converts * {@link org.openqa.selenium.remote.internal.JsonToWebElementConverter}. It converts * JSON response to an instance of * {@link org.openqa.selenium.WebElement} */ Expand All @@ -98,10 +100,10 @@ protected AppiumDriver(HttpCommandExecutor executor, Capabilities capabilities, this.remoteAddress = executor.getAddressOfRemoteServer(); try { Constructor<? extends JsonToWebElementConverter> constructor = converterClazz.getConstructor(RemoteWebDriver.class); converterClazz.getConstructor(RemoteWebDriver.class); this.setElementConverter(constructor.newInstance(this)); } catch (NoSuchMethodException | IllegalAccessException | InstantiationException | InvocationTargetException e) { | InvocationTargetException e) { throw new RuntimeException(e); } } Expand All @@ -114,7 +116,7 @@ public AppiumDriver(URL remoteAddress, Capabilities desiredCapabilities,
public AppiumDriver(URL remoteAddress, HttpClient.Factory httpClientFactory, Capabilities desiredCapabilities, Class<? extends JsonToWebElementConverter> converterClazz) { Class<? extends JsonToWebElementConverter> converterClazz) { this(new AppiumCommandExecutor(MobileCommand.commandRepository, remoteAddress, httpClientFactory), desiredCapabilities, converterClazz); } Expand All @@ -127,7 +129,7 @@ public AppiumDriver(AppiumDriverLocalService service, Capabilities desiredCapabi
public AppiumDriver(AppiumDriverLocalService service, HttpClient.Factory httpClientFactory, Capabilities desiredCapabilities, Class<? extends JsonToWebElementConverter> converterClazz) { Class<? extends JsonToWebElementConverter> converterClazz) { this(new AppiumCommandExecutor(MobileCommand.commandRepository, service, httpClientFactory), desiredCapabilities, converterClazz); } Expand All @@ -139,14 +141,14 @@ public AppiumDriver(AppiumServiceBuilder builder, Capabilities desiredCapabiliti
public AppiumDriver(AppiumServiceBuilder builder, HttpClient.Factory httpClientFactory, Capabilities desiredCapabilities, Class<? extends JsonToWebElementConverter> converterClazz) { Class<? extends JsonToWebElementConverter> converterClazz) { this(builder.build(), httpClientFactory, desiredCapabilities, converterClazz); }
public AppiumDriver(HttpClient.Factory httpClientFactory, Capabilities desiredCapabilities, Class<? extends JsonToWebElementConverter> converterClazz) { this(AppiumDriverLocalService.buildDefaultService(), httpClientFactory, desiredCapabilities, converterClazz); this(AppiumDriverLocalService.buildDefaultService(), httpClientFactory, desiredCapabilities, converterClazz); }
public AppiumDriver(Capabilities desiredCapabilities, Expand All @@ -156,8 +158,8 @@ public AppiumDriver(Capabilities desiredCapabilities,
/** * @param originalCapabilities the given {@link Capabilities}. * @param newPlatform a {@link MobileCapabilityType#PLATFORM_NAME} value which has * to be set up * @param newPlatform a {@link MobileCapabilityType#PLATFORM_NAME} value which has * to be set up * @return {@link Capabilities} with changed mobile platform value */ protected static Capabilities substituteMobilePlatform(Capabilities originalCapabilities, Expand Down Expand Up @@ -409,6 +411,21 @@ public void zoom(int x, int y) { return contextName; }
@Override public DeviceRotation rotation() { Response response = execute(DriverCommand.GET_SCREEN_ROTATION); DeviceRotation deviceRotation = new DeviceRotation((Map<String, Number>) response.getValue()); if (deviceRotation.getX() < 0 || deviceRotation.getY() < 0 || deviceRotation.getZ() < 0) { throw new WebDriverException("Unexpected orientation returned: " + deviceRotation); } return deviceRotation; }
@Override public void rotate(DeviceRotation rotation) { execute(DriverCommand.SET_SCREEN_ROTATION, rotation.parameters()); }

@Override public void rotate(ScreenOrientation orientation) { execute(DriverCommand.SET_SCREEN_ORIENTATION, ImmutableMap.of("orientation", orientation.value().toUpperCase())); Expand Down Expand Up @@ -450,7 +467,6 @@ public URL getRemoteAddress() {
/** * @return a map with values that hold session details. * */ public Map<String, Object> getSessionDetails() { Response response = execute(GET_SESSION); Expand Down