Search code examples
javaandroidseleniumjunitappium

When running Appium tests in parallel using driver.quit() causes the other test(s) to fail


The problem

I am using Java to run JUnit test's in parallel to Appium servers configured with different ports and UUID's for each device. I am running the same test on both phones. It looks like when the test ends on the first phone it somehow interferes with the other phone which is still processing the same test. This results in the error message and stack trace shown below.

This does NOT happen every time. It seems like most of the time the problem occurs but sometimes it will run a test on both without an issue.

driver.quit()/close() As part of the tests we close out the driver at the end using driver.quit(). Doing this causes the behaviour described above. If I REMOVE driver.quit() all the tests will finish successfully. The problem with this is that if I want to run other tests the driver session is still open in Appium and there is no way to close it unless I restart Appium.

Each JUnit test is run on its on Appium port and using the UUID of the device.

Environment

  • Appium version (or git revision) that exhibits the issue: Appium v1.5.3 / Appium Java Client 4.0.0 / Appium 3.4.1

Details

2 Different errors: 1:
org.openqa.selenium.WebDriverException: An unknown server-side error occurred while processing the command. Original error: Android bootstrap socket crashed: Error: This socket has been ended by the other party (WARNING: The server did not provide any stacktrace information)

2: org.openqa.selenium.WebDriverException: An unknown server-side error occurred while processing the command. Original error: Could not proxy. Proxy error: Could not proxy command to remote server. Original error: Error: socket hang up (WARNING: The server did not provide any stacktrace information)


Solution

  • You will need to provide a different --bootstrap-port (-bp) for each Appium session as well. Source: http://appium.io/slate/en/master/?java#parallel-android-tests Edit: documentation for parallel testing is these days found at http://appium.io/docs/en/advanced-concepts/parallel-tests/

    Also, if your parallel tests include usage of Selendroid automation or Chrome/WebView automation, further ports are needed for those:

    --chromedriver-port the chromedriver port (if using webviews or chrome)

    --selendroid-port the selendroid port (if using selendroid)