appium/java-client

Appium 1.7.0 crashes Java client 5.0.3 when testing iOS

welnanick opened this issue · 26 comments

Description

When attempting to use java-client 5.0.3 to test an iOS device with Appium 1.7.0, the java-client crashes with java.lang.NullPointerException: null value in entry: browserName=null

Environment

  • java client build version or git revision if you use some shapshot: 5.0.3
  • Appium server version or git revision if you use some shapshot: 1.7.0
  • Desktop OS/version used to run Appium if necessary: macOS Sierra 10.12.6
  • Node.js version (unless using Appium.app|exe) or Appium CLI or Appium.app|exe: Node.js v8.5.0, Appium 1.7.0
  • Mobile platform/version under test: iOS
  • Real device or emulator/simulator: Real Device

Details

Using the same Appium Server, I can use appium-desktop using the custom server option to connect to the iOS device just fine. Android is unaffected. I believe this chunk of the logs are could relevant:

2017-09-19 22:43:55:863 - info: [HTTP] <-- POST /wd/hub/session 200 23221 ms - 589 
2017-09-19 22:43:55:908 - info: [HTTP] --> GET /wd/hub/session/c4c0364a-9a80-442e-b328-3dbb5d77418b {}
2017-09-19 22:43:55:909 - info: [debug] [MJSONWP] Calling AppiumDriver.getSession() with args: ["c4c0364a-9a80-442e-b328-3dbb5d77418b"]
2017-09-19 22:43:55:909 - info: [debug] [XCUITest] Executing command 'getSession'
2017-09-19 22:43:55:924 - info: [debug] [JSONWP Proxy] Proxying [GET /] to [GET http://localhost:8100/session/25E38EC3-E56F-44E4-806E-9B404F0A9D80] with no body
2017-09-19 22:43:56:103 - info: [debug] [JSONWP Proxy] Got response with status 200: "{\n  \"value\" : {\n    \"sessionId\" : \"25E38EC3-E56F-44E4-806E-9B404F0A9D80\",\n    \"capabilities\" : {\n      \"device\" : \"iphone\",\n      \"browserName\" : null,\n      \"sdkVersion\" : \"10.3.2\",\n      \"CFBundleIdentifier\" : \"local.pid.53\"\n    }\n  },\n  \"sessionId\" : \"25E38EC3-E56F-44E4-806E-9B404F0A9D80\",\n  \"status\" : 0\n}"
2017-09-19 22:43:56:103 - info: [XCUITest] Merging WDA caps over Appium caps for session detail response
2017-09-19 22:43:56:104 - info: [debug] [MJSONWP] Responding to client with driver.getSession() result: {"udid":"67e44e99a952683ca27e8beccc50687bf4a71490","app":"/Users/nwelna/Documents/app-automation/appFiles/ios/app.ipa","xcodeOrgId":"UTURYJS693","automationName":"XCUITest","browserName":null,"platformName":"iOS","deviceName":"Test Device","xcodeSigningId":"iPhone Developer","usePrebuiltWDA":true,"device":"iphone","sdkVersion":"10.3.2","CFBundleIdentifier":"local.pid.53"}
2017-09-19 22:43:56:105 - info: [HTTP] <-- GET /wd/hub/session/c4c0364a-9a80-442e-b328-3dbb5d77418b 200 196 ms - 486 
2017-09-19 22:43:56:196 - info: [Appium] Received SIGTERM - shutting down

Code To Reproduce Issue [ Good To Have ]

Just attempt to connect to a real iOS device

Ecxeption stacktraces

gist

@welnanick I think that something is wrong on the server side.
@SrinivasanTarget could you check session details on iOS with server 1.7.0

@welnanick Can you please attach full server log? It seems like you don't provide all the required capabilities.

@TikhomirovSergey iOS works fine with 1.7.0 and latest java client. @welnanick can you share your sample driver creation code as @mykola-mokhnach suggested along with the pom or gradle file.

Here is the code I am using to create the driver:

        AppiumDriver<MobileElement> driver = null;

        DesiredCapabilities capabilities = new DesiredCapabilities();
        Assert.assertNotNull("platformName is a required argument", System.getProperty("platformName"));
        capabilities.setCapability("platformName", System.getProperty("platformName"));
        if (System.getProperty("platformName").equals("Android")) {

            capabilities.setCapability("appWaitActivity", System.getProperty("appWaitActivity"));
            capabilities.setCapability("app", System.getProperty("appAndroid"));


        }
        else if (System.getProperty("platformName").equals("iOS")) {

            capabilities.setCapability("app", System.getProperty("appiOS"));
            capabilities.setCapability("automationName", System.getProperty("automationName"));
            capabilities.setCapability("xcodeOrgId", System.getProperty("xcodeOrgId"));
            capabilities.setCapability("xcodeSigningId", System.getProperty("xcodeSigningId"));
            capabilities.setCapability("usePrebuiltWDA", System.getProperty("usePrebuiltWDA"));

        }
        capabilities.setCapability("deviceName", System.getProperty("deviceName"));
        Assert.assertNotNull("udid is a required argument", System.getProperty("udid"));
        capabilities.setCapability("udid", System.getProperty("udid"));

        try {
            if (System.getProperty("platformName").equals("iOS")) {
                driver = new IOSDriver<>(new URL(System.getProperty("appiumLocation")), capabilities);
            }
            else {
                driver = new AndroidDriver<>(new URL(System.getProperty("appiumLocation")), capabilities);
            }

        }
        catch (MalformedURLException e) {

            e.printStackTrace();

        }

        if (driver != null) {

            driver.manage().timeouts().implicitlyWait(5, TimeUnit.SECONDS);

        }

        return driver;

With all the system properties defined the above code should result in the following capabilities:

{
  "platformName": "iOS",
  "app": "/Users/nwelna/Documents/app-test-automation/appFiles/ios/app.ipa",
  "automationName": "XCUITest",
  "udid": "67e44e99a952683ca27e8beccc50687bf4a71490",
  "deviceName": "iPhone",
  "updatedWDABundleId": "com.WebDriverAgentRunner",
  "xcodeOrgId": "*orgId*",
  "xcodeSigningId": "iPhone Developer",
  "usePrebuiltWDA": true
}

Again this works for Android, and not iOS, and it worked fine with 1.7.0 Beta. It wasn't until I updated appium yesterday morning that I started having issues.

Here is a gist of the full appium logs up to the crash using the java-client: gist

Also, just discovered appium-desktop is not working as I thought it was, as it can't interact with the 1.7.0 server, so I can't send commands.

Oh, here are my dependencies in gradle:

dependencies {

    testCompile group: 'org.testng', name: 'testng', version: '6.12'
    testCompile group: 'io.appium', name: 'java-client', version: '5.0.3'
    testCompile group: 'com.codepine.api', name: 'testrail-api-java-client', version: '2.0.0'

}

@welnanick i will check in sometime and update you.

@TikhomirovSergey the exception is thrown inside:

    default Map<String, Object> getSessionDetails() {
        Response response = execute(GET_SESSION);
        return  ImmutableMap.<String, Object>builder()
                .putAll(Map.class.cast(response.getValue())).build();
    }

We try to create immutable map on response values, but there is a key with null value there and this causes failure. Probably, it is necessary to perform some preliminary filtering before calling putAll

@mykola-mokhnach Maybe. I will try to improve it soon.

@welnanick said

Again this works for Android, and not iOS, and it worked fine with 1.7.0 Beta. It wasn't until I updated appium yesterday morning that I started having issues.

So this is really intresting deatail

...maybe some empty string was there

Fix is going to be published..

@TikhomirovSergey is there an ETA for when the fix will be published? My iOS testing is currently completely halted due to this bug.

@welnanick We are planning to release 5.1.0 or 5.0.4 soon though there is no exact ETA. I wanted test everything on Selenium 3.6.0 released yesterday before we make a java-client 5.1.0 or 5.0.4. Will keep you posted.

@SrinivasanTarget I've encountered same problem with NullPointerException when using sendKeys() method and Selenium 3.6.0. After downgrading Selenium to 3.4.0 it seems to work properly, so it might be worth looking into.

Versions:
Appium: 1.7.1
java-client: 4.1.2
Android: 7.1

I don't expect any issues as there is not much changes in Selenium 3.6.0. Will check it though. I think you should give a try in latest java client without excluding selenium and adding it again.It should working without any efforts.

I had recently updated to Xcode 9.2. Appium 1.6.3 was not compatible with this Xcode version.
Finally after trying out adifferent versions of appium and java-client and selenium, I found the versions which are working.
I was getting a browserName=null exception while contacting the appium server from the java code before.

Here are the versions which are working with Xcode 9.2
Appium - 1.7.1
Java-client - 5.0.0-BETA7
selenium-java- 3.4.0

Hi,
I am not able use DesiredCapabilities, uisng java client 5.0.4, i getting the following error, pls suggest me.

Error:
DesiredCapabilities cannot be resolved to a type error.

I am using
Appium 1.7.2
Java client 5.0.4
Selenum-Java 2.53.1

@kumarRaghavendra Unfortunately cant help anything here. Give a try in latest java client and raise us issues if you hit any with detailed server logs.

Hi,

Is there any common method or any code snippet, which i can use to scroll and swipe in both android and iOS

i am using below appium and selenium versions

Selenium Version : 3.6.0
java client : 6.0.0-BETA4
TestNG :6.13.1
Appium 1.7.2

I am trying to do scroll and swipe, but i am getting the following error, please help me:

[RemoteTestNG] detected TestNG version 6.13.1
FAILED CONFIGURATION: @BeforeTest setCapabilities
java.lang.NoClassDefFoundError: org/apache/http/auth/Credentials
at io.appium.java_client.remote.AppiumCommandExecutor.(AppiumCommandExecutor.java:73)
at io.appium.java_client.AppiumDriver.(AppiumDriver.java:93)
at com.contacts.BaseClass.setCapabilities(BaseClass.java:25)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(Unknown Source)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(Unknown Source)
at java.lang.reflect.Method.invoke(Unknown Source)
at org.testng.internal.MethodInvocationHelper.invokeMethod(MethodInvocationHelper.java:124)
at org.testng.internal.MethodInvocationHelper.invokeMethodConsideringTimeout(MethodInvocationHelper.java:59)
at org.testng.internal.Invoker.invokeConfigurationMethod(Invoker.java:451)
at org.testng.internal.Invoker.invokeConfigurations(Invoker.java:222)
at org.testng.internal.Invoker.invokeConfigurations(Invoker.java:142)
at org.testng.TestRunner.beforeRun(TestRunner.java:529)
at org.testng.TestRunner.run(TestRunner.java:497)
at org.testng.SuiteRunner.runTest(SuiteRunner.java:455)
at org.testng.SuiteRunner.runSequentially(SuiteRunner.java:450)
at org.testng.SuiteRunner.privateRun(SuiteRunner.java:415)
at org.testng.SuiteRunner.run(SuiteRunner.java:364)
at org.testng.SuiteRunnerWorker.runSuite(SuiteRunnerWorker.java:52)
at org.testng.SuiteRunnerWorker.run(SuiteRunnerWorker.java:84)
at org.testng.TestNG.runSuitesSequentially(TestNG.java:1187)
at org.testng.TestNG.runSuitesLocally(TestNG.java:1116)
at org.testng.TestNG.runSuites(TestNG.java:1028)
at org.testng.TestNG.run(TestNG.java:996)
at org.testng.remote.AbstractRemoteTestNG.run(AbstractRemoteTestNG.java:114)
at org.testng.remote.RemoteTestNG.initAndRun(RemoteTestNG.java:251)
at org.testng.remote.RemoteTestNG.main(RemoteTestNG.java:77)
Caused by: java.lang.ClassNotFoundException: org.apache.http.auth.Credentials
at java.net.URLClassLoader$1.run(Unknown Source)
at java.net.URLClassLoader$1.run(Unknown Source)
at java.security.AccessController.doPrivileged(Native Method)
at java.net.URLClassLoader.findClass(Unknown Source)
at java.lang.ClassLoader.loadClass(Unknown Source)
at sun.misc.Launcher$AppClassLoader.loadClass(Unknown Source)
at java.lang.ClassLoader.loadClass(Unknown Source)
... 27 more

SKIPPED CONFIGURATION: @AfterTest tearDown
SKIPPED: swipeleft
java.lang.NoClassDefFoundError: org/apache/http/auth/Credentials
at io.appium.java_client.remote.AppiumCommandExecutor.(AppiumCommandExecutor.java:73)
at io.appium.java_client.AppiumDriver.(AppiumDriver.java:93)
at com.contacts.BaseClass.setCapabilities(BaseClass.java:25)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(Unknown Source)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(Unknown Source)
at java.lang.reflect.Method.invoke(Unknown Source)
at org.testng.internal.MethodInvocationHelper.invokeMethod(MethodInvocationHelper.java:124)
at org.testng.internal.MethodInvocationHelper.invokeMethodConsideringTimeout(MethodInvocationHelper.java:59)
at org.testng.internal.Invoker.invokeConfigurationMethod(Invoker.java:451)
at org.testng.internal.Invoker.invokeConfigurations(Invoker.java:222)
at org.testng.internal.Invoker.invokeConfigurations(Invoker.java:142)
at org.testng.TestRunner.beforeRun(TestRunner.java:529)
at org.testng.TestRunner.run(TestRunner.java:497)
at org.testng.SuiteRunner.runTest(SuiteRunner.java:455)
at org.testng.SuiteRunner.runSequentially(SuiteRunner.java:450)
at org.testng.SuiteRunner.privateRun(SuiteRunner.java:415)
at org.testng.SuiteRunner.run(SuiteRunner.java:364)
at org.testng.SuiteRunnerWorker.runSuite(SuiteRunnerWorker.java:52)
at org.testng.SuiteRunnerWorker.run(SuiteRunnerWorker.java:84)
at org.testng.TestNG.runSuitesSequentially(TestNG.java:1187)
at org.testng.TestNG.runSuitesLocally(TestNG.java:1116)
at org.testng.TestNG.runSuites(TestNG.java:1028)
at org.testng.TestNG.run(TestNG.java:996)
at org.testng.remote.AbstractRemoteTestNG.run(AbstractRemoteTestNG.java:114)
at org.testng.remote.RemoteTestNG.initAndRun(RemoteTestNG.java:251)
at org.testng.remote.RemoteTestNG.main(RemoteTestNG.java:77)
Caused by: java.lang.ClassNotFoundException: org.apache.http.auth.Credentials
at java.net.URLClassLoader$1.run(Unknown Source)
at java.net.URLClassLoader$1.run(Unknown Source)
at java.security.AccessController.doPrivileged(Native Method)
at java.net.URLClassLoader.findClass(Unknown Source)
at java.lang.ClassLoader.loadClass(Unknown Source)
at sun.misc.Launcher$AppClassLoader.loadClass(Unknown Source)
at java.lang.ClassLoader.loadClass(Unknown Source)
... 27 more

Hello I also had some issues, the only way that I make the test cases work is using the following configuration:

  • Xcode version 9.3
  • selenium-java 3.4.0
  • io.appium java-client 5.0.0-BETA7
  • Appium server 1.7.1

I tried a lots of combinations and this one is more or less working. The test cases fails, seems like some elements are not recognized. I am investigating why. For example, If I change the appium version to 5.0.4 the elements are not recognized:
Message: org.openqa.selenium.WebDriverException: Returned value cannot be converted to WebElement: {ELEMENT=C0929175-9F93-4175-B0F6-F3F597A8BD79} Build info: version: '3.4.0', revision: 'unknown', time: 'unknown' System info: host: os.name: 'Mac OS X', os.arch: 'x86_64', os.version: '10.13.2', java.version: '1.8.0_151' Driver info: driver.version: IOSDriver Stack Trace: org.openqa.selenium.remote.RemoteWebDriver.findElement(RemoteWebDriver.java:417) io.appium.java_client.DefaultGenericMobileDriver.findElement(DefaultGenericMobileDriver.java:62) io.appium.java_client.AppiumDriver.findElement(AppiumDriver.java:1) io.appium.java_client.ios.IOSDriver.findElement(IOSDriver.java:1) org.openqa.selenium.remote.RemoteWebDriver.findElementById(RemoteWebDriver.java:453) io.appium.java_client.DefaultGenericMobileDriver.findElementById(DefaultGenericMobileDriver.java:70) io.appium.java_client.AppiumDriver.findElementById(AppiumDriver.java:1) io.appium.java_client.ios.IOSDriver.findElementById(IOSDriver.java:1) org.openqa.selenium.By$ById.findElement(By.java:218) org.openqa.selenium.remote.RemoteWebDriver.findElement(RemoteWebDriver.java:402) io.appium.java_client.DefaultGenericMobileDriver.findElement(DefaultGenericMobileDriver.java:58) io.appium.java_client.AppiumDriver.findElement(AppiumDriver.java:1) io.appium.java_client.ios.IOSDriver.findElement(IOSDriver.java:1) org.openqa.selenium.support.pagefactory.DefaultElementLocator.findElement(DefaultElementLocator.java:69) org.openqa.selenium.support.pagefactory.internal.LocatingElementHandler.invoke(LocatingElementHandler.java:38)

On the other hand, I couldn't start the selenium-java to an upper version I have this issue:
Message: io.appium.java_client.service.local.AppiumServerHasNotBeenStartedLocallyException: The local appium server has not been started.

Hello,
Have same issue. Here is some details:

Versions:
Appium v1.7.1
io.appium:java-client:5.0.3
node: v7.3.0
MacOs: 10.13.3
iOS Simulator.

Capabilities:
2018-04-20 11:09:11:555 - [HTTP] --> POST /wd/hub/session {"desiredCapabilities":{"CapabilityName":"com.techery.dtat.driver.capabilities.IPhoneCapabilities","app":"/Users/administrator/jenkins/workspace/UITests/AT.DreamTrips.iOS.BuildApp-Tests/../../apps/DreamTrip.app","autoAcceptAlerts":true,"automationName":"XCUITest","defaultCapability":false,"deviceName":"iPhone 7","fullReset":false,"newCommandTimeout":0,"noReset":false,"orientation":"PORTRAIT","platformName":"iOS","platformVersion":"10.3.1","showXcodeLog":true,"udid":"5B439EB7-CEFB-4D1B-A31B-190CD30F8D97","waitForAppScript":"true"},"capabilities":{"desiredCapabilities":{"CapabilityName":"com.techery.dtat.driver.capabilities.IPhoneCapabilities","app":"/Users/administrator/jenkins/workspace/UITests/AT.DreamTrips.iOS.BuildApp-Tests/../../apps/DreamTrip.app","autoAcceptAlerts":true,"automationName":"XCUITest","defaultCapability":false,"deviceName":"iPhone 7","fullReset":false,"newCommandTimeout":0,"noReset":false,"orientation":"PORTRAIT","platformName":"iOS","platformVersion":"10.3.1","showX 2018-04-20 11:09:11:556 - [debug] [MJSONWP] Calling AppiumDriver.createSession() with args: [{"CapabilityName":"com.techery.dtat.driver.capabilities.IPhoneCapabilities","app":"/Users/administrator/jenkins/workspace/UITests/AT.DreamTrips.iOS.BuildApp-Tests/../../apps/DreamTrip.app","autoAcceptAlerts":true,"automationName":"XCUITest","defaultCapability":false,"deviceName":"iPhone 7","fullReset":false,"newCommandTimeout":0,"noReset":false,"orientation":"PORTRAIT","platformName":"iOS","platformVersion":"10.3.1","showXcodeLog":true,"udid":"5B439EB7-CEFB-4D1B-A31B-190CD30F8D97","waitForAppScript":"true"},null,{"desiredCapabilities":{"CapabilityName":"com.techery.dtat.driver.capabilities.IPhoneCapabilities","app":"/Users/administrator/jenkins/workspace/UITests/AT.DreamTrips.iOS.BuildApp-Tests/../../apps/DreamTrip.app","autoAcceptAlerts":true,"automationName":"XCUITest","defaultCapability":false,"deviceName":"iPhone 7","fullReset":false,"newCommandTimeout":0,"noReset":false,"orientation":"PORTRAIT","platformName":"iOS","platformVersion":"10.3.1","showXcodeLog":true,"udid":"5B439EB7-CEFB-4D1B-A31B-190CD30...

Log:
Gradle Test Executor 1 STANDARD_ERROR java.lang.NullPointerException: null value in entry: browserName=null at com.google.common.collect.CollectPreconditions.checkEntryNotNull(CollectPreconditions.java:34) at com.google.common.collect.ImmutableMap.entryOf(ImmutableMap.java:175) at com.google.common.collect.ImmutableMap$Builder.put(ImmutableMap.java:260) at com.google.common.collect.ImmutableMap$Builder.put(ImmutableMap.java:275) at com.google.common.collect.ImmutableMap$Builder.putAll(ImmutableMap.java:303) at com.google.common.collect.ImmutableMap$Builder.putAll(ImmutableMap.java:286) at io.appium.java_client.HasSessionDetails.getSessionDetails(HasSessionDetails.java:38) at io.appium.java_client.HasSessionDetails.getSessionDetail(HasSessionDetails.java:42) at io.appium.java_client.HasSessionDetails.getPlatformName(HasSessionDetails.java:46) at io.appium.java_client.AppiumDriver.<init>(AppiumDriver.java:99) at io.appium.java_client.AppiumDriver.<init>(AppiumDriver.java:122) at io.appium.java_client.ios.IOSDriver.<init>(IOSDriver.java:102)

Appium log:

2018-04-20 11:10:26:118 - [debug] [MJSONWP] Responding to client with driver.getSession() result: {"udid":"5B439EB7-CEFB-4D1B-A31B-190CD30F8D97","CapabilityName":"com.techery.dtat.driver.capabilities.IPhoneCapabilities","app":"/Users/administrator/jenkins/workspace/UITests/AT.DreamTrips.iOS.BuildApp-Tests/../../apps/DreamTrip.app","autoAcceptAlerts":true,"automationName":"XCUITest","defaultCapability":false,"deviceName":"iPhone 7","fullReset":false,"newCommandTimeout":0,"noReset":false,"orientation":"PORTRAIT","platformName":"iOS","platformVersion":"10.3.1","showXcodeLog":true,"waitForAppScript":"true","device":"iphone","browserName":null,"sdkVersion":"10.3.1","CFBundleIdentifier":"local.pid.45641"} 2018-04-20 11:10:26:119 - [HTTP] <-- GET /wd/hub/session/b16c36ba-8e07-4a45-bd9f-818dc52a79aa 200 135 ms - 682 11:10:26.121 [Test worker] ERROR (BaseWait.java:232): Caught an exception not listed in ignored exceptions classes: [class java.lang.NullPointerException]

@victor-kalmus-techery Try to upgrade your client to the recent beta version

Hi,
I haven a problem I think is related to the fix for this issue. Ever since java-client:5.0.4 and upwards getSession() is called between each command to merge in my Desired Capabilities, severely increasing the test time. I have isolated the problem to a change between java-client version 5.0.3 and 5.0.4 and it still persists in the latest BETA version of java-client. It only occurs on iOS devices and only starts occurring when the java-client version is upped (nothing else changed). Is there some way to avoid this behavior?

  • Xcode version 9.2
  • iOS 11.2.5
  • selenium-java 3.11.0
  • io.appium java-client 6.0.0-BETA5
  • Appium server 1.7.2

Appium log snippet: gist

@mykola-mokhnach
I am also facing extreme slowness issue with iOS native apps with the below configuration. Can you please give us some solution for the sudden slowness.
-Xvode version 9.2
-iOS 11.2.5
-Selenium Server Standalone 3.12
-io.appium javaclient 6.0.0
-Appium Server 1.7.2

Please do the needful.

@mykola-mokhnach Thanks a lot.. It worked...