Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 5 additions & 5 deletions azure-pipelines.yml
Original file line number Diff line number Diff line change
Expand Up @@ -4,24 +4,24 @@
# https://docs.microsoft.com/azure/devops/pipelines/languages/java

pool:
vmImage: 'macOS 10.14'
vmImage: 'macOS-10.15'

variables:
ANDROID_EMU_NAME: test
ANDROID_EMU_ABI: x86
ANDROID_EMU_TARGET: android-27
ANDROID_EMU_TAG: google_apis
XCODE_VERSION: 10.2
IOS_PLATFORM_VERSION: 12.2
XCODE_VERSION: 11.5
IOS_PLATFORM_VERSION: 13.5
IOS_DEVICE_NAME: iPhone X

jobs:
- job: E2E_Tests
timeoutInMinutes: 60
timeoutInMinutes: '60'
steps:
- task: NodeTool@0
inputs:
versionSpec: '11.x'
versionSpec: '12.x'

- script: |
echo "Configuring Environment"
Expand Down
4 changes: 3 additions & 1 deletion src/main/java/io/appium/java_client/AppiumDriver.java
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,7 @@
import org.openqa.selenium.WebElement;
import org.openqa.selenium.html5.Location;

import org.openqa.selenium.remote.CapabilityType;
import org.openqa.selenium.remote.DesiredCapabilities;
import org.openqa.selenium.remote.DriverCommand;
import org.openqa.selenium.remote.ErrorHandler;
Expand Down Expand Up @@ -316,7 +317,8 @@ public URL getRemoteAddress() {

@Override
public boolean isBrowser() {
String browserName = CapabilityHelpers.getCapability(getCapabilities(), "browserName", String.class);
String browserName = CapabilityHelpers.getCapability(getCapabilities(),
CapabilityType.BROWSER_NAME, String.class);
if (!isBlank(browserName)) {
try {
return (boolean) executeScript("return !!window.navigator;");
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -43,8 +43,14 @@ public static <T> T getCapability(Capabilities caps, String name, Class<T> expec
possibleNames.add(APPIUM_PREFIX + name);
}
for (String capName : possibleNames) {
if (caps.getCapability(capName) != null
&& expectedType.isAssignableFrom(caps.getCapability(capName).getClass())) {
if (caps.getCapability(capName) == null) {
continue;
}

if (expectedType == String.class) {
return expectedType.cast(String.valueOf(caps.getCapability(capName)));
}
if (expectedType.isAssignableFrom(caps.getCapability(capName).getClass())) {
return expectedType.cast(caps.getCapability(capName));
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,8 +18,10 @@

import static io.appium.java_client.internal.ElementMap.getElementClass;

import io.appium.java_client.remote.MobileCapabilityType;
import org.openqa.selenium.Capabilities;
import org.openqa.selenium.WebDriverException;
import org.openqa.selenium.remote.CapabilityType;
import org.openqa.selenium.remote.RemoteWebDriver;
import org.openqa.selenium.remote.RemoteWebElement;
import org.openqa.selenium.remote.internal.JsonToWebElementConverter;
Expand All @@ -46,8 +48,8 @@ public JsonToMobileElementConverter(RemoteWebDriver driver) {
super(driver);
this.driver = driver;
Capabilities caps = driver.getCapabilities();
this.platform = CapabilityHelpers.getCapability(caps, "platformName", String.class);
this.automation = CapabilityHelpers.getCapability(caps, "automationName", String.class);
this.platform = CapabilityHelpers.getCapability(caps, CapabilityType.PLATFORM_NAME, String.class);
this.automation = CapabilityHelpers.getCapability(caps, MobileCapabilityType.AUTOMATION_NAME, String.class);
}

@Override
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -29,13 +29,14 @@
import io.appium.java_client.ios.IOSElement;
import io.appium.java_client.pagefactory.bys.ContentType;
import io.appium.java_client.pagefactory.locator.CacheableLocator;
import io.appium.java_client.remote.MobileCapabilityType;
import io.appium.java_client.windows.WindowsElement;
import org.openqa.selenium.Capabilities;
import org.openqa.selenium.HasCapabilities;
import org.openqa.selenium.SearchContext;
import org.openqa.selenium.WebDriver;
import org.openqa.selenium.WebElement;
import org.openqa.selenium.remote.RemoteWebDriver;
import org.openqa.selenium.remote.CapabilityType;
import org.openqa.selenium.remote.RemoteWebElement;
import org.openqa.selenium.support.pagefactory.DefaultFieldDecorator;
import org.openqa.selenium.support.pagefactory.ElementLocator;
Expand All @@ -49,6 +50,7 @@
import java.time.Duration;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.Collections;
import java.util.List;
import java.util.Map;

Expand Down Expand Up @@ -88,8 +90,8 @@ public AppiumFieldDecorator(SearchContext context, Duration duration) {

if (this.webDriver instanceof HasCapabilities) {
Capabilities caps = ((HasCapabilities) this.webDriver).getCapabilities();
this.platform = CapabilityHelpers.getCapability(caps, "platformName", String.class);
this.automation = CapabilityHelpers.getCapability(caps, "automationName", String.class);
this.platform = CapabilityHelpers.getCapability(caps, CapabilityType.PLATFORM_NAME, String.class);
this.automation = CapabilityHelpers.getCapability(caps, MobileCapabilityType.AUTOMATION_NAME, String.class);
} else {
this.platform = null;
this.automation = null;
Expand All @@ -107,8 +109,7 @@ protected WebElement proxyForLocator(ClassLoader ignored, ElementLocator locator

@Override
@SuppressWarnings("unchecked")
protected List<WebElement> proxyForListLocator(ClassLoader ignored,
ElementLocator locator) {
protected List<WebElement> proxyForListLocator(ClassLoader ignored, ElementLocator locator) {
ElementListInterceptor elementInterceptor = new ElementListInterceptor(locator);
return getEnhancedProxy(ArrayList.class, elementInterceptor);
}
Expand All @@ -125,19 +126,12 @@ protected boolean isDecoratableList(Field field) {
}

Type listType = ((ParameterizedType) genericType).getActualTypeArguments()[0];
List<Type> bounds = (listType instanceof TypeVariable)
? Arrays.asList(((TypeVariable<?>) listType).getBounds())
: Collections.emptyList();

for (Class<? extends WebElement> webElementClass : availableElementClasses) {
if (webElementClass.equals(listType)) {
return true;
}
}

if ((listType instanceof TypeVariable)
&& Arrays.asList(((TypeVariable<?>) listType).getBounds())
.stream().anyMatch(item -> availableElementClasses.contains(item))) {
return true;
}
return false;
return availableElementClasses.stream()
.anyMatch((webElClass) -> webElClass.equals(listType) || bounds.contains(webElClass));
}
};

Expand Down Expand Up @@ -188,10 +182,10 @@ private Object decorateWidget(Field field) {
}

if (listType instanceof Class) {
if (!Widget.class.isAssignableFrom((Class) listType)) {
if (!Widget.class.isAssignableFrom((Class<?>) listType)) {
return null;
}
widgetType = Class.class.cast(listType);
widgetType = (Class<? extends Widget>) listType;
} else {
return null;
}
Expand Down
25 changes: 3 additions & 22 deletions src/test/java/io/appium/java_client/ios/IOSTouchTest.java
Original file line number Diff line number Diff line change
Expand Up @@ -5,19 +5,16 @@
import static io.appium.java_client.touch.WaitOptions.waitOptions;
import static io.appium.java_client.touch.offset.ElementOption.element;
import static java.time.Duration.ofMillis;
import static java.time.Duration.ofSeconds;
import static org.junit.Assert.assertEquals;
import static org.junit.Assert.assertNotNull;
import static org.openqa.selenium.support.ui.ExpectedConditions.alertIsPresent;

import io.appium.java_client.MobileElement;
import io.appium.java_client.MultiTouchAction;
import io.appium.java_client.TouchAction;
import io.appium.java_client.touch.offset.ElementOption;
import org.junit.FixMethodOrder;
import org.junit.Test;
import org.junit.runners.MethodSorters;
import org.openqa.selenium.Dimension;
import org.openqa.selenium.support.ui.WebDriverWait;

@FixMethodOrder(MethodSorters.NAME_ASCENDING)
Expand All @@ -33,7 +30,7 @@ public void tapTest() {
intB.sendKeys("4");

MobileElement e = driver.findElementByAccessibilityId("ComputeSumButton");
new TouchAction(driver).tap(tapOptions().withElement(element(e))).perform();
new IOSTouchAction(driver).tap(tapOptions().withElement(element(e))).perform();
assertEquals(driver.findElementByXPath("//*[@name = \"Answer\"]").getText(), "6");
}

Expand All @@ -57,28 +54,12 @@ public void touchWithPressureTest() {
assertEquals(driver.findElementByXPath("//*[@name = \"Answer\"]").getText(), "6");
}

@Test public void swipeTest() {
WebDriverWait webDriverWait = new WebDriverWait(driver, 30);
IOSElement slider = webDriverWait.until(driver1 -> driver.findElementByClassName("XCUIElementTypeSlider"));
Dimension size = slider.getSize();

ElementOption press = element(slider, size.width / 2 + 2, size.height / 2);
ElementOption move = element(slider, 1, size.height / 2);

TouchAction swipe = new TouchAction(driver).press(press)
.waitAction(waitOptions(ofSeconds(2)))
.moveTo(move).release();

swipe.perform();
assertEquals("0%", slider.getAttribute("value"));
}

@Test public void multiTouchTest() {
MobileElement e = driver.findElementByAccessibilityId("ComputeSumButton");
MobileElement e2 = driver.findElementByAccessibilityId("show alert");

TouchAction tap1 = new TouchAction(driver).tap(tapOptions().withElement(element(e)));
TouchAction tap2 = new TouchAction(driver).tap(tapOptions().withElement(element(e2)));
IOSTouchAction tap1 = new IOSTouchAction(driver).tap(tapOptions().withElement(element(e)));
IOSTouchAction tap2 = new IOSTouchAction(driver).tap(tapOptions().withElement(element(e2)));

new MultiTouchAction(driver).add(tap1).add(tap2).perform();

Expand Down