Appium 1.7.0 crashes Java client 5.0.3 when testing iOS
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
@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.
SKIPPED CONFIGURATION: @AfterTest tearDown
SKIPPED: swipeleft
java.lang.NoClassDefFoundError: org/apache/http/auth/Credentials
at io.appium.java_client.remote.AppiumCommandExecutor.
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.