Skip to content

Commit

Permalink
updated tests and CIIntegration
Browse files Browse the repository at this point in the history
Try travis to execute tests

update travis config

update travis config

list devices and appium version

try travis

try travis

try travis

try travis

try travis

try travis

skip installation in travis

skip installation in travis

try travis

try travis

try travis

try travis

Update travis.yml

try iOS Driver

update travis

Run entire package

Run entire package

Run entire package

Run entire package

Update to check URL

Update to check URL

Run entire android package

Fix iOS tests and integrate with CI

Fix iOS tests and integrate with CI

Run on any branch in travis

address review comments

Address review comments

Fix tests

fix tests

fix tests

fix pullfile test and exclude timeout test

fix review comments

make codacy happy

Ignore webviewtest
  • Loading branch information
SrinivasanTarget committed Jun 19, 2018
1 parent 05fa225 commit ed47f96
Show file tree
Hide file tree
Showing 28 changed files with 364 additions and 373 deletions.
45 changes: 39 additions & 6 deletions .travis.yml
Original file line number Diff line number Diff line change
@@ -1,10 +1,43 @@
language: java

jdk:
- oraclejdk8

sudo: required

install: true

script: ./gradlew clean build -x test -x signArchives
matrix:
include:
- language: java
install: true
os: osx
osx_image: xcode9.3
before_install:
- brew update
- brew outdated xctool || brew upgrade xctool
- npm install -g appium
script:
- ./gradlew clean xcuiTest -x signArchives
# - language: android
# install: true
# os: linux
# jdk: oraclejdk8
# android:
# components:
# - build-tools-26.0.2
# - platform-tools
# - tools
# - android-22
# - extra-android-m2repository
# - extra-google-google_play_services
# - extra-google-m2repository
# - sys-img-armeabi-v7a-android-22
# before_install:
# # node stuff
# - curl -o- https://raw.githubusercontent.com/creationix/nvm/v0.33.1/install.sh | bash
# - nvm install 6
# - node --version
# - npm --version
# - npm install -g [email protected]
# - echo no | android create avd --force -n test -t android-22 --abi armeabi-v7a
# - emulator -avd test -no-audio -no-window &
# - android-wait-for-emulator
# - adb devices
# script:
# - ./gradlew clean test --tests "io.appium.java_client.android.*" --exclude-task signArchives
26 changes: 24 additions & 2 deletions build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -196,8 +196,30 @@ uploadArchives {
}
}

wrapper.gradleVersion = '4.5.1'
wrapper.gradleVersion = '4.8'

test {
task xcuiTest( type: Test ) {
useJUnit()
testLogging.showStandardStreams = true
testLogging.exceptionFormat = 'full'
filter {
includeTestsMatching '*.appium.element.generation.ios.*'
includeTestsMatching '*.appium.AppiumFluentWaitTest'
includeTestsMatching 'io.appium.java_client.ios.*'
includeTestsMatching '*.pagefactory_tests.XCUITModeTest'
includeTestsMatching '*.pagefactory_tests.widget.tests.combined.*'
includeTestsMatching '*.pagefactory_tests.widget.tests.ios.*'
includeTestsMatching '*.StartingAppLocallyTest.startingIOSAppWithCapabilitiesAndServiceTest'
includeTestsMatching '*.StartingAppLocallyTest.startingIOSAppWithCapabilitiesAndFlagsOnServerSideTest'
exclude '**/UIAutomationTest.class'
exclude '**/IOSScreenRecordTest.class'
exclude '**/ImagesComparisonTest.class'
}
}

task uiAutomationTest( type: Test ) {
useJUnit()
testLogging.showStandardStreams = true
testLogging.exceptionFormat = 'full'
include '**/UIAutomationTest.class'
}
3 changes: 2 additions & 1 deletion gradle/wrapper/gradle-wrapper.properties
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
#Mon Feb 26 22:51:40 IST 2018
distributionBase=GRADLE_USER_HOME
distributionPath=wrapper/dists
zipStoreBase=GRADLE_USER_HOME
zipStorePath=wrapper/dists
distributionUrl=https\://services.gradle.org/distributions/gradle-4.5.1-bin.zip
distributionUrl=https\://services.gradle.org/distributions/gradle-4.5.1-all.zip
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@
import static io.appium.java_client.android.AndroidMobileCommandHelper.endTestCoverageCommand;
import static io.appium.java_client.android.AndroidMobileCommandHelper.openNotificationsCommand;
import static io.appium.java_client.android.AndroidMobileCommandHelper.toggleLocationServicesCommand;
import static org.openqa.selenium.remote.CapabilityType.PLATFORM_NAME;
import static org.openqa.selenium.remote.DriverCommand.EXECUTE_SCRIPT;

import com.google.common.collect.ImmutableMap;
Expand All @@ -37,6 +38,7 @@
import io.appium.java_client.service.local.AppiumServiceBuilder;
import io.appium.java_client.ws.StringWebSocketClient;
import org.openqa.selenium.Capabilities;
import org.openqa.selenium.MutableCapabilities;
import org.openqa.selenium.WebElement;
import org.openqa.selenium.remote.HttpCommandExecutor;
import org.openqa.selenium.remote.http.HttpClient;
Expand Down Expand Up @@ -197,6 +199,12 @@ public AndroidBatteryInfo getBatteryInfo() {
"script", "mobile: batteryInfo", "args", Collections.emptyList())).getValue());
}

public Capabilities getCapabilities() {
MutableCapabilities capabilities = (MutableCapabilities) super.getCapabilities();
capabilities.setCapability(PLATFORM_NAME, ANDROID_PLATFORM);
return capabilities;
}

@Override
public synchronized StringWebSocketClient getLogcatClient() {
if (logcatClient == null) {
Expand Down
8 changes: 8 additions & 0 deletions src/main/java/io/appium/java_client/ios/IOSDriver.java
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@

import static io.appium.java_client.MobileCommand.RUN_APP_IN_BACKGROUND;
import static io.appium.java_client.MobileCommand.prepareArguments;
import static org.openqa.selenium.remote.CapabilityType.PLATFORM_NAME;
import static org.openqa.selenium.remote.DriverCommand.EXECUTE_SCRIPT;

import com.google.common.collect.ImmutableMap;
Expand All @@ -37,6 +38,7 @@
import io.appium.java_client.ws.StringWebSocketClient;
import org.openqa.selenium.Alert;
import org.openqa.selenium.Capabilities;
import org.openqa.selenium.MutableCapabilities;
import org.openqa.selenium.WebElement;
import org.openqa.selenium.remote.DriverCommand;
import org.openqa.selenium.remote.HttpCommandExecutor;
Expand Down Expand Up @@ -201,6 +203,12 @@ private class InnerTargetLocator extends RemoteTargetLocator {
}
}

public Capabilities getCapabilities() {
MutableCapabilities capabilities = (MutableCapabilities) super.getCapabilities();
capabilities.setCapability(PLATFORM_NAME, IOS_PLATFORM);
return capabilities;
}


class IOSAlert implements Alert {

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ public class UIAutomator2Test {

if (service == null || !service.isRunning()) {
throw new AppiumServerHasNotBeenStartedLocallyException(
"An appium server node is not started!");
"An appium server node is not started!");
}

File appDir = new File("src/test/java/io/appium/java_client");
Expand Down Expand Up @@ -92,20 +92,20 @@ public class UIAutomator2Test {
popUpElement.click();
driver.findElement(By.xpath(".//*[@text='Search']")).click();
assertNotNull(wait.until(ExpectedConditions.presenceOfElementLocated(
By.xpath("//*[@text='Clicked popup menu item Search']"))));
By.xpath("//*[@text='Clicked popup menu item Search']"))));

popUpElement.click();
driver.findElement(By.xpath(".//*[@text='Add']")).click();
assertNotNull(wait.until(ExpectedConditions
.presenceOfElementLocated(By.xpath("//*[@text='Clicked popup menu item Add']"))));
.presenceOfElementLocated(By.xpath("//*[@text='Clicked popup menu item Add']"))));

popUpElement.click();
driver.findElement(By.xpath(".//*[@text='Edit']")).click();
assertNotNull(wait.until(ExpectedConditions
.presenceOfElementLocated(By.xpath("//*[@text='Clicked popup menu item Edit']"))));
.presenceOfElementLocated(By.xpath("//*[@text='Clicked popup menu item Edit']"))));

driver.findElement(By.xpath(".//*[@text='Share']")).click();
assertNotNull(wait.until(ExpectedConditions
.presenceOfElementLocated(By.xpath("//*[@text='Clicked popup menu item Share']"))));
.presenceOfElementLocated(By.xpath("//*[@text='Clicked popup menu item Share']"))));
}
}
91 changes: 0 additions & 91 deletions src/test/java/io/appium/java_client/appium/IOSTest.java

This file was deleted.

Original file line number Diff line number Diff line change
@@ -1,19 +1,23 @@
package io.appium.java_client.appium.element.generation.ios;

import static io.appium.java_client.MobileBy.IosUIAutomation;
import static io.appium.java_client.MobileBy.AccessibilityId;
import static org.junit.Assert.assertTrue;
import static org.openqa.selenium.By.id;
import static org.openqa.selenium.By.name;
import static org.openqa.selenium.By.partialLinkText;

import io.appium.java_client.appium.element.generation.BaseElementGenerationTest;
import io.appium.java_client.ios.IOSElement;
import io.appium.java_client.remote.IOSMobileCapabilityType;
import io.appium.java_client.remote.MobileBrowserType;
import io.appium.java_client.remote.MobileCapabilityType;
import io.appium.java_client.remote.MobilePlatform;
import org.junit.Ignore;
import org.junit.Test;
import org.openqa.selenium.Capabilities;
import org.openqa.selenium.remote.DesiredCapabilities;
import org.openqa.selenium.support.ui.ExpectedConditions;
import org.openqa.selenium.support.ui.WebDriverWait;

import java.io.File;
import java.util.function.Function;
Expand All @@ -25,14 +29,14 @@ public class IOSElementGenerationTest extends BaseElementGenerationTest {
"TestApp.app.zip");

private final File webViewApp = new File(new File("src/test/java/io/appium/java_client"),
"WebViewApp.app.zip");
"vodqa.zip");

private Supplier<DesiredCapabilities> serverAppCapabilitiesSupplier = () -> {
DesiredCapabilities serverCapabilities = new DesiredCapabilities();
serverCapabilities.setCapability(MobileCapabilityType.DEVICE_NAME, "iPhone Simulator");
serverCapabilities.setCapability(MobileCapabilityType.DEVICE_NAME, "iPhone 8");
serverCapabilities.setCapability(IOSMobileCapabilityType.LAUNCH_TIMEOUT,
500000); //some environment is too slow
serverCapabilities.setCapability(MobileCapabilityType.PLATFORM_VERSION, "9.2");
serverCapabilities.setCapability(MobileCapabilityType.PLATFORM_VERSION, "11.3");
serverCapabilities.setCapability(MobileCapabilityType.PLATFORM_NAME, MobilePlatform.IOS);
return serverCapabilities;
};
Expand All @@ -48,8 +52,8 @@ public class IOSElementGenerationTest extends BaseElementGenerationTest {
private final Supplier<DesiredCapabilities> serverBrowserCapabilitiesSupplier = () -> {
DesiredCapabilities serverCapabilities = new DesiredCapabilities();
serverCapabilities.setCapability(MobileCapabilityType.BROWSER_NAME, MobileBrowserType.SAFARI);
serverCapabilities.setCapability(MobileCapabilityType.PLATFORM_VERSION, "9.2");
serverCapabilities.setCapability(MobileCapabilityType.DEVICE_NAME, "iPhone Simulator");
serverCapabilities.setCapability(MobileCapabilityType.PLATFORM_VERSION, "11.3");
serverCapabilities.setCapability(MobileCapabilityType.DEVICE_NAME, "iPhone 8");
//sometimes environment has performance problems
serverCapabilities.setCapability(IOSMobileCapabilityType.LAUNCH_TIMEOUT, 500000);
return serverCapabilities;
Expand All @@ -66,17 +70,21 @@ public void whenIOSNativeAppIsLaunched() {
assertTrue(check(serverAppCapabilitiesSupplier,
appFileSupplierFunction.apply(testApp),
commonPredicate,
IosUIAutomation(".elements().withName(\"Answer\")"),
AccessibilityId("Answer"),
IOSElement.class));
}

@Test public void whenIOSHybridAppIsLaunched() {
@Test @Ignore public void whenIOSHybridAppIsLaunched() {
assertTrue(check(serverAppCapabilitiesSupplier,
appFileSupplierFunction.apply(webViewApp),
(by, aClass) -> {
IOSElement element1 = (IOSElement) driver.findElementByXPath("//UIATextField[@value='Enter URL']");
element1.sendKeys("www.google.com");
driver.findElementByClassName("UIAButton").click();
new WebDriverWait(driver, 30)
.until(ExpectedConditions.presenceOfElementLocated(id("login")))
.click();
driver.findElementByAccessibilityId("webView").click();
new WebDriverWait(driver, 30)
.until(ExpectedConditions
.presenceOfElementLocated(AccessibilityId("Webview")));
try {
Thread.sleep(10000);
} catch (InterruptedException e) {
Expand All @@ -88,7 +96,7 @@ public void whenIOSNativeAppIsLaunched() {
}
});
return commonPredicate.test(by, aClass);
}, name("q"), IOSElement.class));
}, partialLinkText("login"), IOSElement.class));
}

@Test public void whenIOSBrowserIsLaunched() {
Expand All @@ -103,15 +111,15 @@ public void whenIOSNativeAppIsLaunched() {
public void whenIOSNativeAppIsLaunched2() {
assertTrue(check(() -> {
DesiredCapabilities serverCapabilities = serverAppCapabilitiesSupplier.get();
serverCapabilities.setCapability(MobileCapabilityType.PLATFORM_VERSION, "10.1");
serverCapabilities.setCapability(MobileCapabilityType.PLATFORM_VERSION, "11.3");
return serverCapabilities;
}, appFileSupplierFunction.apply(testApp), commonPredicate, id("IntegerA"), IOSElement.class));
}

@Test public void whenIOSBrowserIsLaunched2() {
assertTrue(check(() -> {
DesiredCapabilities serverCapabilities = serverBrowserCapabilitiesSupplier.get();
serverCapabilities.setCapability(MobileCapabilityType.PLATFORM_VERSION, "10.1");
serverCapabilities.setCapability(MobileCapabilityType.PLATFORM_VERSION, "11.3");
return serverCapabilities;
}, clientBrowserCapabilitiesSupplier, (by, aClass) -> {
driver.get("https://www.google.com");
Expand Down
Loading

0 comments on commit ed47f96

Please sign in to comment.