Passing browserName as Appium server capabilities keeps waiting after launching empty browser

System details:
ChromeDriver 2.20.353124
Appium 1.4.16
Mac OS X Yosemite Version 10.10.5

I am trying to pass browserName but I get error as below.
desired_caps = dict()
desired_caps[‘platformName’] = ‘Android’
desired_caps[‘platformVersion’] = ‘6.0’
desired_caps[‘deviceName’] = ‘Android Emulator’
desired_caps[‘appActivity’] = ‘com.google.android.gms.app.settings.GoogleSettingsActivity’
desired_caps[‘appPackage’] = ‘com.google.android.gms’
desired_caps[‘newCommandTimeout’] = 1000
desired_caps[‘browserName’] = ‘Chrome’
self.driver = webdriver.Remote(‘http://localhost:4723/wd/hub’, desired_caps)

It works fine if I remove desired_caps['browserName'] = 'Chrome'

Sometimes after long time I get error BadStatusLine: ''

info: Welcome to Appium v1.4.16 (REV ae6877eff263066b26328d457bd285c0cc62430d)
info: Appium REST http interface listener started on 0.0.0.0:4723
info: Console LogLevel: debug
info: --> POST /wd/hub/session {"desiredCapabilities":{"deviceName":"Android Emulator","browserName":"Chrome","newCommandTimeout":1000,"platformVersion":"6.0","appPackage":"com.google.android.gms","platformName":"Android","appActivity":"com.google.android.gms.app.settings.GoogleSettingsActivity"}}
info: Client User-Agent string: Python-urllib/2.7
info: Set mode: Proxying straight through to Chromedriver
info: [debug] Looks like we want chrome on android
info: [debug] Creating new appium session 5a48aef0-8791-4ff2-a7cf-d73acae1feea
info: [debug] Checking whether adb is present
info: [debug] Using adb from /Users/adt-bundle-mac-x86_64-20140702/sdk/platform-tools/adb
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: /Users/adt-bundle-mac-x86_64-20140702/sdk/platform-tools/adb devices
info: [debug] 1 device(s) connected
info: Found device 9276da93
info: [debug] Setting device id to 9276da93
info: [debug] Waiting for device to be ready and to respond to shell commands (timeout = 5)
info: [debug] executing cmd: /Users/adt-bundle-mac-x86_64-20140702/sdk/platform-tools/adb -s 9276da93 wait-for-device
info: [debug] executing cmd: /Users/adt-bundle-mac-x86_64-20140702/sdk/platform-tools/adb -s 9276da93 shell "echo 'ready'"
info: [debug] Starting logcat capture
info: [debug] Pushing unlock helper app to device...
info: [debug] executing cmd: /Users/adt-bundle-mac-x86_64-20140702/sdk/platform-tools/adb -s 9276da93 install "/usr/local/lib/node_modules/appium/build/unlock_apk/unlock_apk-debug.apk"
info: [debug] executing cmd: /Users/adt-bundle-mac-x86_64-20140702/sdk/platform-tools/adb -s 9276da93 shell "dumpsys window"
info: [debug] Screen already unlocked, continuing.
info: [debug] Forwarding system:4724 to device:4724
info: [debug] executing cmd: /Users/adt-bundle-mac-x86_64-20140702/sdk/platform-tools/adb -s 9276da93 forward tcp:4724 tcp:4724
info: [debug] Pushing appium bootstrap to device...
info: [debug] executing cmd: /Users/adt-bundle-mac-x86_64-20140702/sdk/platform-tools/adb -s 9276da93 push "/usr/local/lib/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: /Users/adt-bundle-mac-x86_64-20140702/sdk/platform-tools/adb -s 9276da93 shell "ps 'uiautomator'"
info: [debug] No matching processes found
info: [debug] Running bootstrap
info: [debug] spawning: /Users/adt-bundle-mac-x86_64-20140702/sdk/platform-tools/adb -s 9276da93 shell uiautomator runtest AppiumBootstrap.jar -c io.appium.android.bootstrap.Bootstrap -e pkg com.android.chrome -e disableAndroidWatchers false
info: [debug] [UIAUTOMATOR STDOUT] INSTRUMENTATION_STATUS: numtests=1
info: [debug] [UIAUTOMATOR STDOUT] INSTRUMENTATION_STATUS: stream=
info: [debug] [UIAUTOMATOR STDOUT] io.appium.android.bootstrap.Bootstrap:
info: [debug] [UIAUTOMATOR STDOUT] INSTRUMENTATION_STATUS: id=UiAutomatorTestRunner
info: [debug] [UIAUTOMATOR STDOUT] INSTRUMENTATION_STATUS: test=testRunServer
info: [debug] [UIAUTOMATOR STDOUT] INSTRUMENTATION_STATUS: class=io.appium.android.bootstrap.Bootstrap
info: [debug] [UIAUTOMATOR STDOUT] INSTRUMENTATION_STATUS: current=1
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] Pushing command to appium work queue: ["getDataDir",{}]
info: [debug] [BOOTSTRAP] [debug] Registered crash watchers.
info: [debug] [BOOTSTRAP] [debug] Client connected
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] dataDir set to: /data/local/tmp
info: Chromedriver: Changed state to 'starting'
info: [debug] [BOOTSTRAP] [debug] Returning result: {"status":0,"value":"\/data\/local\/tmp"}
info: Chromedriver: Set chromedriver binary as: /usr/local/lib/node_modules/appium/node_modules/appium-chromedriver/chromedriver/mac/chromedriver
info: Chromedriver: Killing any old chromedrivers, running: ps -ef | grep /usr/local/lib/node_modules/appium/node_modules/appium-chromedriver/chromedriver/mac/chromedriver | grep -v grep |grep -e '--port=9515\(\s.*\)\?$' | awk '{ print $2 }' | xargs kill -15
info: Chromedriver: Successfully cleaned up old chromedrivers
info: Chromedriver: Spawning chromedriver with: /usr/local/lib/node_modules/appium/node_modules/appium-chromedriver/chromedriver/mac/chromedriver --url-base=wd/hub --port=9515
info: Chromedriver: [STDOUT] Starting ChromeDriver 2.20.353124 (035346203162d32c80f1dce587c8154a1efa0c3b) on port 9515
Only local connections are allowed.
info: JSONWP Proxy: Proxying [GET /status] to [GET http://127.0.0.1:9515/wd/hub/status] with no body
info: JSONWP Proxy: Got response with status 200: "{\"sessionId\":\"\",\"status\":0,\"value\":{\"build\":{\"version\":\"alpha\"},\"os\":{\"arch\":\"x86_64\",\"name\":\"Mac OS X\",\"version\":\"10.10.5\"}}}"
info: JSONWP Proxy: Proxying [POST /session] to [POST http://127.0.0.1:9515/wd/hub/session] with body: {"desiredCapabilities":{"chromeOptions":{"androidPackage":"com.android.chrome","androidDeviceSerial":"9276da93"}}}
info: JSONWP Proxy: Got response with status 200: {"sessionId":"10e70688e268822165ed79725b1d0877","status":0,"value":{"acceptSslCerts":true,"applicationCacheEnabled":false,"browserConnectionEnabled":false,"browserName":"chrome","chrome":{},"cssSel...
info: Chromedriver: Changed state to 'online'
info: [debug] Overriding session id with "10e70688e268822165ed79725b1d0877"
info: [debug] Device launched! Ready for commands
info: [debug] Setting command timeout to 1000 secs
info: [debug] Appium session started with sessionId 10e70688e268822165ed79725b1d0877
info: <-- POST /wd/hub/session 303 9919.695 ms - 70 
info: --> GET /wd/hub/session/10e70688e268822165ed79725b1d0877 {}
info: JSONWP Proxy: Proxying [GET /wd/hub/session/10e70688e268822165ed79725b1d0877] to [GET http://127.0.0.1:9515/wd/hub/session/10e70688e268822165ed79725b1d0877] with body: {}
info: JSONWP Proxy: Got response with status 200: {"sessionId":"10e70688e268822165ed79725b1d0877","status":0,"value":{"acceptSslCerts":true,"applicationCacheEnabled":false,"browserConnectionEnabled":false,"browserName":"chrome","chrome":{},"cssSel...
info: JSONWP Proxy: Replacing sessionId 10e70688e268822165ed79725b1d0877 with 10e70688e268822165ed79725b1d0877
info: <-- GET /wd/hub/session/10e70688e268822165ed79725b1d0877 200 6.259 ms - 528 
info: --> GET /wd/hub/session/10e70688e268822165ed79725b1d0877/appium/device/current_activity {}
info: JSONWP Proxy: Proxying [GET /wd/hub/session/10e70688e268822165ed79725b1d0877/appium/device/current_activity] to [GET http://127.0.0.1:9515/wd/hub/session/10e70688e268822165ed79725b1d0877/appium/device/current_activity] with body: {}
error: Could not proxy command to remote server. Original error: 404 - unknown command: session/10e70688e268822165ed79725b1d0877/appium/device/current_activity

Hey there:
In my desired capabilities I have this included and things work well:

app = “Browser”
browserName = “Browser”

It’s an old device and it doesn’t have chrome installed - rather the stock browser but it works.

In your case, setting both of the above to ‘Chome’ should make things work. Let me know if it doesn’t and I can look further

Thanks!

Thanks for the response !
I tried with those parameters
desired_caps[‘app’] = ‘Chrome’
desired_caps[‘browserName’] = ‘Chrome’

But I still get same error

You should not provide these capablities if you are automation browser. Below are my configuration.

  DesiredCapabilities cap = new DesiredCapabilities();
  cap.setCapability("automationName", "Appium");
  cap.setCapability("platformName", "Android");
  cap.setCapability("deviceName", "emulator-5554");
  cap.setCapability("platformVersion", "4.4");
  cap.setCapability("appiumVersion", "1.4.8");
  cap.setCapability("browserName", "chrome");
  cap.setCapability("newCommandTimeout", "7200");
  cap.setCapability("fullReset", true);
  driver = new AndroidDriver<WebElement>(new URL("http://localhost:4723/wd/hub"), cap);

I tried below but I am still getting same error:

desired_caps = dict()
desired_caps['platformName'] = 'Android'
desired_caps['platformVersion'] = '6.0'
desired_caps['deviceName'] = 'Android Emulator'
desired_caps['newCommandTimeout'] = 1000
desired_caps['browserName'] = 'Chrome'
desired_caps['fullReset'] = 'true'
self.driver = webdriver.Remote('http://localhost:4723/wd/hub', desired_caps)

Sandesh, your last log statement in your original post is suspicious:

Not sure right now. I’d comb through this link and make sure everything is in order: https://github.com/appium/appium/blob/master/docs/en/writing-running-appium/mobile-web.md

If you want, I can take a look at your APK
E

I am just launching some in-built app e.g. above I’m just launching google settings. I am not trying to launch my app, just open browser and launch any website and any in built apps. I will try to run with other network maybe office network is blocking things? But that might not be issue because if I don’t mention browserName by default it launched Chrome browser and it works fine. But if I add browserName parameter it gives error

Hi sandesh. I’ll try this myself and see if I can reproduce. I assume you are using the stock android emulator?
Eric

I am using actual device.

OK:

So I went on my genymotion emulator (I don’t have a device here at home - they’re at the office - I can try tomorrow) I was able to prune down my device capabilities to this and things worked for me. (see below inline)
(Full Disclosure: Trying to install Chrome in the genymotion emulator failed for genymotion/my environment reasons - not Appium)

Update: Tried also this morning on Nexus 10 5.0 Device with Chrome. Switched Browser to Chrome in my caps, all worked well.

[caps]
platformName = "Android"
platformVersion = "5.0"
deviceName = "Android Emulator"
browserName = "Browser"
[appium_lib]
port = 4900
  1. So I compared the appium log I get upon my success with the log you provided on your failure. The only additional item I found is that you are on Mac OS X 10.10.5. I am on 10.11. Not sure if that matters here.

  2. I’m assuming that
    a. you are using the latest Appium Version as of this email (1.4.16)
    b. you are not specifiying a specific chromedriver-executable in your appium server arguments.

  3. I’m taking a stab this but essentially Appium believes that your session is invalid. The closest post I found comes from here: https://groups.google.com/forum/#!topic/appium-discuss/C-qsVULrp5g . You can read more about it. It looks like there were problems with older versions of ChromeDriver.

  4. If you’re up for it, you can read up on the source where I believe that error would manifest. I’m looking at line 53 of https://github.com/appium/appium/blob/cdadd16d216abbe9838ed48a37af7d0aaed67150/lib/server/controller.js

Summary: Here’s what I would do.

  1. Make sure you have the latest Appium installed. There had been fixes around web context issues in recent releases. With 1.4.16, I haven’t had the need to use any modified chromedriver capabilities.
  2. You may want to try on a different network. If you’ve gone through a proxy server, it’s possible you may have tripped up another bug.
  3. If that’s the case, you can file tickets at https://github.com/appium/appium/issues - I didn’t see anything at quick glance that matched your issue.
  4. Taking the browserName capability out defaults to a native context. You may get your activities to launch, but you won’t be able to interrogate your elements correctly on your external web browser of choice.

I hope this is helpful. At this point, I don’t think I can offer anymore :smile:
Best of luck
Eric

Thanks Eric !
I am using latest version of appium as well chromedriver, I updated in post.
I tried changing ports for appium and chromedriver.
I tried passing ports through command line arguments.
I tried on different network.
I guess at this point I will try to file as bug
Thanks again

1 Like

Issue is fixed with latest appium release v1.5.0-beta9.
desired_caps['browserName'] = 'Chrome'