Difficulty with Browser/Chromium on android emulator and chromedriver

The past few days have been my first interactions with Appium. I’m having some difficulties establishing a connection to various browsers on an android emulator.

First of all, I did not realize that one cannot install Chrome on an Android Emulator: Installing Chrome for Android on an emulator

I decided to follow the instructions on that website and install ChromiumTestShell on the emulator that I’m using. Appium server is running, and I run my test, and the error I get is:

error: Chromedriver create session did not work. Status was 200 and body was {“sessionId”:“b7eb298b56ce32e9cc3e89f7a38b5583”,“status”:13,“value”:{“message”:“unknown error: Failed to start org.chromium.chrome.testshell on device emulator-5554: Starting: Intent { dat=data:, cmp=org.chromium.chrome.testshell/com.google.android.apps.chrome.Main }\r\nError type 3\r\nError: Activity class {org.chromium.chrome.testshell/com.google.android.apps.chrome.Main} does not exist.\r\n\n (Driver info: chromedriver=2.10.267521,platform=Windows NT 6.1 SP1 x86_64)”}}

So basically, chromedriver can’t find the particular install of Chromium that is on the emulator.

Next I attempt to test the native Browser. That somewhat works; the browser is opened (and then later closed), but I get the following error in appium:

error: Chromedriver create session did not work. Status was 200 and body was {“sessionId”:“c13729264af1e69085387c015a166cf0”,“status”:100,“value”:{“message”:“chrome not reachable\n (Driver info: chromedriver=2.10.267521,platform=Windows NT 6.1 SP1 x86_64)”}}

So the chromedriver that came with Appium couldn’t connect with the native Browser?

Here is the code I was using in my test:

AppiumDriver driver;

DesiredCapabilities capabilities = new DesiredCapabilities();
capabilities.SetCapability("browserName", "Browser");
capabilities.SetCapability("platformName", "Android");
capabilities.SetCapability("platformVersion", "4.3.1");
capabilities.SetCapability("deviceName", "Android Emulator");

driver = new AppiumDriver(new Uri("http://127.0.0.1:4723/wd/hub"), capabilities, TimeSpan.FromSeconds(120));

driver.Navigate().GoToUrl("http://bing.com/");
driver.Manage().Timeouts().ImplicitlyWait(TimeSpan.FromSeconds(60));

The only difference is that I set “browserName” to “Chromium” for the first situation described above.

Any advice or help? I’m using Appium for Windows version 1.2.4.1.

thanks,
Chris

Let me make my questions simpler…

What are the appropriate capabilities to set for Chromium (ChromiumTestShell)?

What are the appropriate capabilities to set for the default Android Browser?

thanks,
Chris

@crichmond

These are the capabilities i used for Android Browser on emulator.

	new DesiredCapabilities();
	DesiredCapabilities capabilities = DesiredCapabilities.android();
	capabilities.setCapability(MobileCapabilityType.BROWSER_NAME, "Browser");
	capabilities.setCapability(MobileCapabilityType.PLATFORM, "Android");
	capabilities.setCapability(MobileCapabilityType.PLATFORM_NAME,"Android");
	capabilities.setCapability(MobileCapabilityType.DEVICE_NAME,"Android Emulator");
	capabilities.setCapability(MobileCapabilityType.VERSION, "4.4.2"); 

	try 
	{
		url = new URL("http://127.0.0.1:4723/wd/hub");
		driver = new AppiumDriver(url, capabilities);
		driver.manage().timeouts().implicitlyWait(120, TimeUnit.SECONDS);
		driver.manage().timeouts().pageLoadTimeout(120, TimeUnit.SECONDS);
	}
	catch (MalformedURLException e) 
	{
		System.out.println("URL init error");
	}

Cheers

I tried your suggestion and still got the same error. I think the issue is with chromedriver.

thanks,
Chris

@crichmond

Try replacing the existing chromedriver.exe with an older version say 2.3 …
The location is
Appium\node_modules\appium\build\chromedriver
I did this in the beginning when i got the chromedriver error.

Cheers

Hi,

I get the same error when using chromedriver 2.3, as well as the latest chromedriver, 2.11.

Ram, are you using AppiumDriver as your driver (I assume)?

thanks,
Chris

@crichmond With the latest java-client version , i am using AndroidDriver() not AppiumDriver()

I’m testing with .NET. For what it’s worth, I was able to install Chrome on android emulators (I’m not exactly sure what that works, perhaps because I’m using an ARM CPU instead of an Intel CPU – the chrome.apk might only work with an ARM simulated processor).

My trouble now is: webpages take longer than 60 seconds to load, and no matter what I specify the command timeout to be, that command timeout is always the default value of 60 seconds.

I believe that is a bug that I’ve mentioned in the issues/bugs section:

@crichmond

Navigate to this location inside your appium folder

 AppiumForWindows-1.2.4.1\Appium\node_modules\appium\lib

And edit the appium.js file by changing the following lines

  this.defCommandTimeoutMs = this.args.defaultCommandTimeout;
  this.commandTimeoutMs = this.defCommandTimeoutMs;

to

  this.defCommandTimeoutMs = this.args.defaultCommandTimeout * 5000;
  this.commandTimeoutMs = this.defCommandTimeoutMs * 5;

This did the trick for me

Cheers.

Hello. I have the same problem, but unfortunatelly your tricks didn’t work for me.

I have Android Emulator (so - without Chrome! Only default, Android Browser), set as Nexus 7 with Android 4.3.1.

I use C#.

Versions of my soft:

  • Appium v1.4.0 (REV 8f63e2f91ef7907aed8bda763f4e5ca08e86970a)
  • Appium Windows GUI 1.4.0.0
  • nunit 2.6.4.14350
  • selenium WebDriver 2.46.0.0
  • selenium WebDriver.Support 2.46.0.0
  • appium-dotnet-driver 1.3.0.1
  • ChromeDriver 2.15.322448 (52179c1b310fec1797c81ea9a20326839860b7d3) (I mean C:\Program Files (x86)\Appium\node_modules\appium\build\chromedriver\windows\chromedriver.exe)

When I run tests, session is created and Default Android Browser is run, but in nUnit is exception:

AppiumC.AppiumTestSuite.CheckTestEnvironment:
SetUp : OpenQA.Selenium.WebDriverException : The HTTP request to the remote WebDriver server for URL http://127.0.0.1:4723/wd/hub/session timed out after 60 seconds.
  ----> System.Net.WebException : The operation has timed out

at OpenQA.Selenium.Remote.HttpCommandExecutor.CreateResponse(WebRequest request)
at OpenQA.Selenium.Remote.RemoteWebDriver.Execute(String driverCommandToExecute, Dictionary`2 parameters)
at OpenQA.Selenium.Remote.RemoteWebDriver.StartSession(ICapabilities desiredCapabilities)
at OpenQA.Selenium.Appium.AppiumDriver`1..ctor(ICommandExecutor commandExecutor, ICapabilities desiredCapabilities)
at AppiumC.AppiumTestSuite.BeforeAll() in c:\Users\dziewannakusinska\Documents\Visual Studio 2013\Projects\AppiumC\AppiumC\Class1.cs:line 35
--WebException
at System.Net.HttpWebRequest.GetResponse()
at OpenQA.Selenium.Remote.HttpCommandExecutor.CreateResponse(WebRequest request)

Am I able to run Appium tests on default browser? Or the only solution is to get and install Chrome on emulator (how? Is it legal?)

I also tried to change chromedriver port, but it didn’t helps.

From appium logs:

Checking if an update is available
Update not available
Starting Node Server
warn: Appium support for versions of node < 0.12 has been deprecated and will be removed in a future version. Please upgrade!
info: Welcome to Appium v1.4.0 (REV 8f63e2f91ef7907aed8bda763f4e5ca08e86970a)
info: Appium REST http interface listener started on 127.0.0.1:4723
info: [debug] Non-default server args: {“address”:“127.0.0.1”,“logNoColors”:true,“platformName”:“Android”,“platformVersion”:“18”,“automationName”:“Appium”}
info: Console LogLevel: debug
info: → POST /wd/hub/session {“desiredCapabilities”:{“deviceName”:“emulator”,“platform”:“Android”,“browserName”:“Browser”,“platformName”:“Android”}}
info: Client User-Agent string: undefined
info: [debug] The following desired capabilities were provided, but not recognized by appium. They will be passed on to any other services running on this server. : platform
info: Set mode: Proxying straight through to Chromedriver
info: [debug] Looks like we want chrome on android
info: [debug] Creating new appium session 92168a23-2812-40e2-9e01-e1388d3b1779
info: [debug] Checking whether adb is present
info: [debug] Using adb from C:\Program Files (x86)\Android\android-sdk\platform-tools\adb.exe
info: [debug] Using fast reset? true
info: [debug] Preparing device for session
info: [debug] Not checking whether app is present since we are assuming it’s already on the device
info: Retrieving device
info: [debug] Trying to find a connected android device
info: [debug] Getting connected devices…
info: [debug] executing cmd: “C:\Program Files (x86)\Android\android-sdk\platform-tools\adb.exe” devices
info: [debug] 1 device(s) connected
info: Found device emulator-5554
info: [debug] Setting device id to emulator-5554
info: [debug] Waiting for device to be ready and to respond to shell commands (timeout = 5)
info: [debug] executing cmd: “C:\Program Files (x86)\Android\android-sdk\platform-tools\adb.exe” -s emulator-5554 wait-for-device
info: [debug] executing cmd: “C:\Program Files (x86)\Android\android-sdk\platform-tools\adb.exe” -s emulator-5554 shell “echo ‘ready’”
info: [debug] Starting logcat capture
info: [debug] Set chromedriver binary as: C:\Program Files (x86)\Appium\node_modules\appium\build\chromedriver\windows\chromedriver.exe
info: Set chromedriver binary as: C:\Program Files (x86)\Appium\node_modules\appium\build\chromedriver\windows\chromedriver.exe
info: [debug] Pushing unlock helper app to device…
info: [debug] executing cmd: “C:\Program Files (x86)\Android\android-sdk\platform-tools\adb.exe” -s emulator-5554 install “C:\Program Files (x86)\Appium\node_modules\appium\build\unlock_apk\unlock_apk-debug.apk”
info: [debug] executing cmd: “C:\Program Files (x86)\Android\android-sdk\platform-tools\adb.exe” -s emulator-5554 shell “dumpsys window”
info: [debug] Screen already unlocked, continuing.
info: [debug] Forwarding system:4724 to device:4724
info: [debug] executing cmd: “C:\Program Files (x86)\Android\android-sdk\platform-tools\adb.exe” -s emulator-5554 forward tcp:4724 tcp:4724
info: [debug] Pushing appium bootstrap to device…
info: [debug] executing cmd: “C:\Program Files (x86)\Android\android-sdk\platform-tools\adb.exe” -s emulator-5554 push “C:\Program Files (x86)\Appium\node_modules\appium\build\android_bootstrap\AppiumBootstrap.jar” /data/local/tmp/
info: Starting App
info: [debug] Attempting to kill all ‘uiautomator’ processes
info: [debug] Getting all processes with ‘uiautomator’
info: [debug] executing cmd: “C:\Program Files (x86)\Android\android-sdk\platform-tools\adb.exe” -s emulator-5554 shell “ps ‘uiautomator’”
info: [debug] No matching processes found
info: [debug] Running bootstrap
info: [debug] spawning: C:\Program Files (x86)\Android\android-sdk\platform-tools\adb.exe -s emulator-5554 shell uiautomator runtest AppiumBootstrap.jar -c io.appium.android.bootstrap.Bootstrap -e pkg com.android.browser -e disableAndroidWatchers false
info: [debug] [UIAUTOMATOR STDOUT] INSTRUMENTATION_STATUS: current=1
info: [debug] [UIAUTOMATOR STDOUT] INSTRUMENTATION_STATUS: id=UiAutomatorTestRunner
info: [debug] [UIAUTOMATOR STDOUT] INSTRUMENTATION_STATUS: class=io.appium.android.bootstrap.Bootstrap
info: [debug] [UIAUTOMATOR STDOUT] INSTRUMENTATION_STATUS: stream=
info: [debug] [UIAUTOMATOR STDOUT] io.appium.android.bootstrap.Bootstrap:
info: [debug] [UIAUTOMATOR STDOUT] INSTRUMENTATION_STATUS: numtests=1
info: [debug] [UIAUTOMATOR STDOUT] INSTRUMENTATION_STATUS: test=testRunServer
info: [debug] [UIAUTOMATOR STDOUT] INSTRUMENTATION_STATUS_CODE: 1
info: [debug] [BOOTSTRAP] [debug] Socket opened on port 4724
info: [debug] [BOOTSTRAP] [debug] Appium Socket Server Ready
info: [debug] [BOOTSTRAP] [debug] Loading json…
info: [debug] [BOOTSTRAP] [debug] Registered crash watchers.
info: [debug] Pushing command to appium work queue: [“getDataDir”,{}]
info: [debug] [BOOTSTRAP] [debug] Client connected
info: [debug] dataDir set to: /data
info: Killing any old chromedrivers, running: FOR /F “usebackq tokens=5” %a in (netstat -nao ^| findstr /R /C:"9515 ") do (FOR /F “usebackq” %b in (TASKLIST /FI "PID eq %a" ^| findstr /I chromedriver.exe) do (IF NOT %b==“” TASKKILL /F /PID %a))
info: [debug] [BOOTSTRAP] [debug] Got data from client: {“cmd”:“action”,“action”:“getDataDir”,“params”:{}}
info: [debug] [BOOTSTRAP] [debug] Got command of type ACTION
info: [debug] [BOOTSTRAP] [debug] Got command action: getDataDir
info: [debug] [BOOTSTRAP] [debug] Returning result: {“value”:“/data”,“status”:0}
info: No old chromedrivers seemed to exist
info: Spawning chromedriver with: C:\Program Files (x86)\Appium\node_modules\appium\build\chromedriver\windows\chromedriver.exe --url-base=wd/hub --port=9515
info: [CHROMEDRIVER STDOUT] Starting ChromeDriver 2.15.322448 (52179c1b310fec1797c81ea9a20326839860b7d3) on port 9515
Only local connections are allowed.
info: Proxying [GET /status] to [GET http://127.0.0.1:9515/wd/hub/status] with no body
info: Got response with status 200: {“sessionId”:“”,“status”:0,“value”:{“build”:{“version”:“alpha”},“os”:{“arch”:“x86_64”,“name”:“Windows NT”,“version”:“6.1 SP1”}}}
info: Proxying [POST /session] to [POST http://127.0.0.1:9515/wd/hub/session] with body: {“desiredCapabilities”:{“chromeOptions”:{“androidPackage”:“com.android.browser”,“androidActivity”:“com.android.browser.BrowserActivity”,“androidDeviceSerial”:“emulator-5554”}}}
info: ← POST /wd/hub/session - - ms - -
info: Got response with status 200: {“sessionId”:“0b056001aad649a740e7684221e53bd1”,“status”:100,“value”:{“message”:"chrome not reachable\n (Driver info: chromedriver=2.15.322448 (52179c1b310fec1797c81ea9a20326839860b7d3),platform=Wind…
info: Proxying [POST /session] to [POST http://127.0.0.1:9515/wd/hub/session] with body: {“desiredCapabilities”:{“chromeOptions”:{“androidPackage”:“com.android.browser”,“androidActivity”:“com.android.browser.BrowserActivity”,“androidDeviceSerial”:“emulator-5554”}}}
info: Got response with status 200: {“sessionId”:“37fb3c1410c340f0b938497e1faa2c4c”,“status”:100,“value”:{“message”:"chrome not reachable\n (Driver info: chromedriver=2.15.322448 (52179c1b310fec1797c81ea9a20326839860b7d3),platform=Wind…
info: Proxying [POST /session] to [POST http://127.0.0.1:9515/wd/hub/session] with body: {“desiredCapabilities”:{“chromeOptions”:{“androidPackage”:“com.android.browser”,“androidActivity”:“com.android.browser.BrowserActivity”,“androidDeviceSerial”:“emulator-5554”}}}
info: Got response with status 200: {“sessionId”:“ff684a16f27f8a7834975a1d5484cf7d”,“status”:100,“value”:{“message”:"chrome not reachable\n (Driver info: chromedriver=2.15.322448 (52179c1b310fec1797c81ea9a20326839860b7d3),platform=Wind…
info: Proxying [POST /session] to [POST http://127.0.0.1:9515/wd/hub/session] with body: {“desiredCapabilities”:{“chromeOptions”:{“androidPackage”:“com.android.browser”,“androidActivity”:“com.android.browser.BrowserActivity”,“androidDeviceSerial”:“emulator-5554”}}}
info: Got response with status 200: {“sessionId”:“ef0a0e9219921df3df4fd0cd1e3d1725”,“status”:100,“value”:{“message”:"chrome not reachable\n (Driver info: chromedriver=2.15.322448 (52179c1b310fec1797c81ea9a20326839860b7d3),platform=Wind…
info: Proxying [POST /session] to [POST http://127.0.0.1:9515/wd/hub/session] with body: {“desiredCapabilities”:{“chromeOptions”:{“androidPackage”:“com.android.browser”,“androidActivity”:“com.android.browser.BrowserActivity”,“androidDeviceSerial”:“emulator-5554”}}}
info: Got response with status 200: {“sessionId”:“afe433824f889edea48fd5c577ac03b2”,“status”:100,“value”:{“message”:"chrome not reachable\n (Driver info: chromedriver=2.15.322448 (52179c1b310fec1797c81ea9a20326839860b7d3),platform=Wind…
info: Proxying [POST /session] to [POST http://127.0.0.1:9515/wd/hub/session] with body: {“desiredCapabilities”:{“chromeOptions”:{“androidPackage”:“com.android.browser”,“androidActivity”:“com.android.browser.BrowserActivity”,“androidDeviceSerial”:“emulator-5554”}}}
info: Got response with status 200: {“sessionId”:“6b5c58daf5e0a0073dd89a4d6a4fc9c3”,“status”:100,“value”:{“message”:"chrome not reachable\n (Driver info: chromedriver=2.15.322448 (52179c1b310fec1797c81ea9a20326839860b7d3),platform=Wind…
info: Proxying [POST /session] to [POST http://127.0.0.1:9515/wd/hub/session] with body: {“desiredCapabilities”:{“chromeOptions”:{“androidPackage”:“com.android.browser”,“androidActivity”:“com.android.browser.BrowserActivity”,“androidDeviceSerial”:“emulator-5554”}}}
info: Got response with status 200: {“sessionId”:“cd8b240342090ac813445ee3a87f8860”,“status”:100,“value”:{“message”:"chrome not reachable\n (Driver info: chromedriver=2.15.322448 (52179c1b310fec1797c81ea9a20326839860b7d3),platform=Wind…
info: Proxying [POST /session] to [POST http://127.0.0.1:9515/wd/hub/session] with body: {“desiredCapabilities”:{“chromeOptions”:{“androidPackage”:“com.android.browser”,“androidActivity”:“com.android.browser.BrowserActivity”,“androidDeviceSerial”:“emulator-5554”}}}

Finally I found workaround: create emulator in higher settings (API 23, Android 6) but what if I also need tests on older version of Android?