Chrome browser closes right after it loads first test step (does not continue execution)

3,781 views
Skip to first unread message

Ravid Te

unread,
Feb 12, 2014, 3:01:10 AM2/12/14
to appium-...@googlegroups.com
Hey Guys,

New here, facing some issues with using Chrome on Android Emulator.  My automation only executes the first navigation step and closes the browser before the next one will execute.

I have tried using the Intel Atom x86 CPU which performs faster, but only get chrome browser flashes (opens really fast then closes really fast).

I then switched to the ARM CPU which is slower, but gets me further. 

Here is my environment:

OS: OSX 10.9.1
Android Emulator:  4.3 API Level 18
          CPU: ARM 
Appium: v0.15.0 
Chrome driver: v2.9
          Chrome browser: 32.0.1700.99 
 

Here is my code:

DesiredCapabilities cap = new DesiredCapabilities();

// android simulator
cap.setCapability("device", "Android");
cap.setCapability("app", "chrome");

driver = new RemoteWebDriver(new URL("http://127.0.0.1:4723/wd/hub"), cap);

driver.get("http://www.google.com");
driver.get("http://www.bing.com");

driver.quit();


My problem:

Emulator shows chrome browser opening, then shows "data.;" in the url for a second or two, then changes to: http://www.google.com.
Once google.com loads, the chrome browser closes immediately and does not proceed to http://www.bing.com.


Here is my log output:
info: Welcome to Appium v0.15.0 (REV a7fc7c504d3b15f52d549f1da3da67634feb395e)
info: Appium REST http interface listener started on 127.0.0.1:4723
info  - socket.io started
info: Spawning instruments force-quitting watcher process
info: [FQInstruments STDERR] Force quit unresponsive instruments v0.0.1
debug: Appium request initiated at /wd/hub/session
debug: Request received with params: {"desiredCapabilities":{"app":"chrome","device":"Android"}}
info: Looks like we want chrome on android
info: Creating new appium session 4092fea7-31eb-452f-a810-6074b7711c9d
info: Ensuring Chromedriver exists
debug: Pushing unlock helper app to device...
debug: executing: adb install "/Users/vid401t/Work/automation/mobile/appium/build/unlock_apk/unlock_apk-debug.apk"
debug: executing: adb shell "dumpsys window"
info: Writing dumpsys output to /Users/vid401t/Work/automation/mobile/appium/.dumpsys.log
debug: Screen already unlocked, continuing.
info: Killing any old chromedrivers, running: ps -e | grep /Users/vid401t/Work/automation/mobile/appium/build/chromedriver | grep -v grep |grep -e '--port=9515$' | awk '{ print $1 }' | xargs kill -15
info: Successfully cleaned up old chromedrivers
info: Spawning chromedriver with: /Users/vid401t/Work/automation/mobile/appium/build/chromedriver
info: [CHROMEDRIVER] Starting ChromeDriver (v2.9.248307) on port 9515
info: Creating Chrome session
info: Making http request with opts: {"url":"http://127.0.0.1:9515/wd/hub/session","method":"POST","json":{"sessionId":null,"desiredCapabilities":{"chromeOptions":{"androidPackage":"com.android.chrome"}}}}
info: Successfully started chrome session
info: Overriding session id with "a792450804fdf2bad37baee2bd467f35"
info: Device launched! Ready for commands (will time out in 60secs)
info: Appium session started with sessionId a792450804fdf2bad37baee2bd467f35
POST /wd/hub/session 303 15713ms - 9b
debug: 127.0.0.1 - - "POST /wd/hub/session HTTP/1.1" 303 9 "-" "-"
debug: Appium request initiated at /wd/hub/session/a792450804fdf2bad37baee2bd467f35
debug: Request received with params: {}
debug: Proxying command to 127.0.0.1:9515
info: Making http request with opts: {"url":"http://127.0.0.1:9515/wd/hub/session/a792450804fdf2bad37baee2bd467f35","method":"GET"}
debug: Proxied response received with status 200: "{\"sessionId\":\"a792450804fdf2bad37baee2bd467f35\",\"status\":0,\"value\":{\"acceptSslCerts\":true,\"applicationCacheEnabled\":false,\"browserConnectionEnabled\":false,\"browserName\":\"chrome\",\"chrome\":{},\"cssSelectorsEnabled\":true,\"databaseEnabled\":false,\"handlesAlerts\":true,\"javascriptEnabled\":true,\"locationContextEnabled\":true,\"nativeEvents\":true,\"platform\":\"ANDROID\",\"rotatable\":false,\"takesHeapSnapshot\":true,\"takesScreenshot\":true,\"version\":\"32.0.1700.99\",\"webStorageEnabled\":true}}"
GET /wd/hub/session/a792450804fdf2bad37baee2bd467f35 200 5ms - 475b
debug: 127.0.0.1 - - "GET /wd/hub/session/a792450804fdf2bad37baee2bd467f35 HTTP/1.1" 200 475 "-" "-"
debug: Appium request initiated at /wd/hub/session/a792450804fdf2bad37baee2bd467f35/url
debug: Request received with params: {"url":"http://www.google.com"}
debug: Proxying command to 127.0.0.1:9515
info: Making http request with opts: {"url":"http://127.0.0.1:9515/wd/hub/session/a792450804fdf2bad37baee2bd467f35/url","method":"POST","json":{"url":"http://www.google.com"}}
debug: Proxied response received with status 200: {"sessionId":"a792450804fdf2bad37baee2bd467f35","status":0,"value":null}
POST /wd/hub/session/a792450804fdf2bad37baee2bd467f35/url 200 11300ms - 85b
debug: 127.0.0.1 - - "POST /wd/hub/session/a792450804fdf2bad37baee2bd467f35/url HTTP/1.1" 200 85 "-" "-"
debug: Appium request initiated at /wd/hub/session/a792450804fdf2bad37baee2bd467f35
debug: Request received with params: {}
info: Shutting down appium session...
info: Killing chromedriver
info: Chromedriver exited with code null
info: (killed by signal SIGTERM)
info: [ADB] Getting connected devices...
debug: executing: adb devices
info: [ADB] 1 device(s) connected
debug: executing: adb shell "am force-stop com.android.chrome"
info: Cleaning up appium session
info: Responding to client with success: {"status":0,"value":null,"sessionId":"a792450804fdf2bad37baee2bd467f35"}
DELETE /wd/hub/session/a792450804fdf2bad37baee2bd467f35 200 2661ms - 85b
debug: 127.0.0.1 - - "DELETE /wd/hub/session/a792450804fdf2bad37baee2bd467f35 HTTP/1.1" 200 85 "-" "-"

Any ideas?

Thanks in advance,
~Ravid

Ravid Te

unread,
Feb 12, 2014, 3:07:45 AM2/12/14
to appium-...@googlegroups.com
Just to add, 

I have also rooted my device with the below commands:

$ adb shell
root@generic:/ # su   
root@generic:/ # chmod 777 /data/local/

Sravani Mohan

unread,
Feb 12, 2014, 6:25:44 AM2/12/14
to appium-...@googlegroups.com
I am also facing the same issue with Chrome in Android emulator 4.4. API level 19.

Regards,
Sravani

Jonathan Lipps

unread,
Feb 12, 2014, 12:58:41 PM2/12/14
to Ravid Te, appium-...@googlegroups.com
Something is definitely shutting down the session from your code. Check this out:

debug: Appium request initiated at /wd/hub/session/a792450804fdf2bad37baee2bd467f35
debug: Request received with params: {}
info: Shutting down appium session...
info: Killing chromedriver
info: Chromedriver exited with code null
info: (killed by signal SIGTERM)
info: [ADB] Getting connected devices...
debug: executing: adb devices
info: [ADB] 1 device(s) connected
debug: executing: adb shell "am force-stop com.android.chrome"
info: Cleaning up appium session
info: Responding to client with success: {"status":0,"value":null,"sessionId":"a792450804fdf2bad37baee2bd467f35"}
DELETE /wd/hub/session/a792450804fdf2bad37baee2bd467f35 200 2661ms - 85b

That's something calling DELETE session on the server.

It could be there's a problem that your code encounters and as a result it ends the session.

--
http://appium.io
---
You received this message because you are subscribed to the Google Groups "Appium-discuss" group.
To unsubscribe from this group and stop receiving emails from it, send an email to appium-discus...@googlegroups.com.
Visit this group at http://groups.google.com/group/appium-discuss.
For more options, visit https://groups.google.com/groups/opt_out.

Ravid Te

unread,
Feb 12, 2014, 1:07:37 PM2/12/14
to Jonathan Lipps, appium-...@googlegroups.com
Hey Jonathan,

Thanks for the fast response.

I don't see anything really inherently wrong with the code, do you see anything abnormal?
Or do you see any tips on how I can debug this?

Lastly, what environment do you use that works for you?  Maybe I can gather all the same versions and try again.

OS: OSX 10.9.1
Android Emulator:  4.3 API Level 18
          CPU: ARM 
Appium: v0.15.0 
Chrome driver: v2.9
          Chrome browser: 32.0.1700.99 

Appreciate the help,
~Ravid

Jonathan Lipps

unread,
Feb 12, 2014, 1:32:57 PM2/12/14
to Ravid Te, appium-...@googlegroups.com
try putting a sleep after the first get() and see whether it shuts down immediately or only after the sleep. that could give us a clue.

is there any output from your test runner itself? like a stack trace?

Ravid Te

unread,
Feb 12, 2014, 2:14:10 PM2/12/14
to Jonathan Lipps, appium-...@googlegroups.com
Hey Jonathan,

So I added a 20second sleep in the code after the first get (below), and it still closes after the google URL is reached (doesn't wait 20 seconds after):

driver.get("http://www.google.com");

try {Thread.sleep(20000);} catch (InterruptedException e) {e.printStackTrace();}


No error output is seen either on the java console in eclipse where I'm running the sample code.

Attaching a short .mov to showcase what I'm seeing (using the appium gui tool).


Any thoughts?

Thanks,

~Ravid

appium-issue.mov

Jonathan Lipps

unread,
Feb 12, 2014, 3:17:06 PM2/12/14
to Ravid Te, appium-...@googlegroups.com
Yeah I'm stumped. I have no clue what could be talking to the appium server, but something is pinging it with a DELETE. It's not shutting down internally. Can you try without appium.app?

On Feb 12, 2014, at 12:01 AM, Ravid Te <vid...@gmail.com> wrote:

Ravid Te

unread,
Feb 12, 2014, 4:20:46 PM2/12/14
to Jonathan Lipps, appium-...@googlegroups.com
Hey Jonathan,

Same thing occurs when running appium from command line instead of using the appium.app.

Looking at the logs again, when the browser navigates to google, I see this:

debug: Appium request initiated at /wd/hub/session/c0d2e39474acd06f45533c9d82ba289d/url


debug: Request received with params: {"url":"http://www.google.com"}
debug: Proxying command to 127.0.0.1:9515

info: Making http request with opts: {"url":"http://127.0.0.1:9515/wd/hub/session/c0d2e39474acd06f45533c9d82ba289d/url","method":"POST","json":{"url":"http://www.google.com"}}


When the browser tried to navigate to bing as the next step, I see this:


debug: Appium request initiated at /wd/hub/session/c0d2e39474acd06f45533c9d82ba289d


debug: Request received with params: {}
info: Shutting down appium session...


Any ideas on why the params is empty?  Could it be why the browser crashes b/c it doesn't understand how to handle empty params?

Just throwing ideas out.


Thanks,
~Ravid

Ravid Te

unread,
Feb 12, 2014, 4:41:15 PM2/12/14
to Jonathan Lipps, appium-...@googlegroups.com
Sorry just to add,

Not sure how helpful it will be but the java console does produce some errors after some time once the chrome browser crashes (didn't notice it before),

Feb 12, 2014 4:35:34 PM org.apache.http.impl.client.DefaultRequestDirector tryExecute
INFO: I/O exception (org.apache.http.NoHttpResponseException) caught when processing request: The target server failed to respond
Feb 12, 2014 4:35:34 PM org.apache.http.impl.client.DefaultRequestDirector tryExecute
INFO: Retrying request
Exception in thread "main" org.openqa.selenium.remote.UnreachableBrowserException: Error communicating with the remote browser. It may have died.
Build info: version: '2.30.0', revision: 'dc1ef9c', time: '2013-02-19 00:15:27'
System info: os.name: 'Mac OS X', os.arch: 'x86_64', os.version: '10.9.1', java.version: '1.6.0_65'
Driver info: driver.version: RemoteWebDriver
at org.openqa.selenium.remote.RemoteWebDriver.execute(RemoteWebDriver.java:548)
at org.openqa.selenium.remote.RemoteWebDriver.execute(RemoteWebDriver.java:569)
at org.openqa.selenium.remote.RemoteWebDriver.quit(RemoteWebDriver.java:423)
at iPhoneAutomationDemo.AppiumTester.run(AppiumTester.java:50)
at iPhoneAutomationDemo.AppiumTester.main(AppiumTester.java:23)
Caused by: org.apache.http.conn.HttpHostConnectException: Connection to http://localhost:4723 refused
at org.apache.http.impl.conn.DefaultClientConnectionOperator.openConnection(DefaultClientConnectionOperator.java:190)
at org.apache.http.impl.conn.AbstractPoolEntry.open(AbstractPoolEntry.java:151)
at org.apache.http.impl.conn.AbstractPooledConnAdapter.open(AbstractPooledConnAdapter.java:125)
at org.apache.http.impl.client.DefaultRequestDirector.tryExecute(DefaultRequestDirector.java:701)
at org.apache.http.impl.client.DefaultRequestDirector.execute(DefaultRequestDirector.java:517)
at org.apache.http.impl.client.AbstractHttpClient.execute(AbstractHttpClient.java:906)
at org.openqa.selenium.remote.HttpCommandExecutor.fallBackExecute(HttpCommandExecutor.java:332)
at org.openqa.selenium.remote.HttpCommandExecutor.execute(HttpCommandExecutor.java:311)
at org.openqa.selenium.remote.RemoteWebDriver.execute(RemoteWebDriver.java:527)
... 4 more
Caused by: java.net.ConnectException: Connection refused
at java.net.PlainSocketImpl.socketConnect(Native Method)
at java.net.PlainSocketImpl.doConnect(PlainSocketImpl.java:382)
at java.net.PlainSocketImpl.connectToAddress(PlainSocketImpl.java:241)
at java.net.PlainSocketImpl.connect(PlainSocketImpl.java:228)
at java.net.SocksSocketImpl.connect(SocksSocketImpl.java:431)
at java.net.Socket.connect(Socket.java:527)
at org.apache.http.conn.scheme.PlainSocketFactory.connectSocket(PlainSocketFactory.java:127)
at org.apache.http.impl.conn.DefaultClientConnectionOperator.openConnection(DefaultClientConnectionOperator.java:180)
... 12 more

Jonathan Lipps

unread,
Feb 12, 2014, 5:07:44 PM2/12/14
to Ravid Te, appium-...@googlegroups.com
where does that error get thrown in your code exactly

Ravid Te

unread,
Feb 12, 2014, 5:52:04 PM2/12/14
to Jonathan Lipps, appium-...@googlegroups.com
Here is the output for the lines:


line 23 is just calling my method:

        run();

line 50 is below:

        try {

            driver = new RemoteWebDriver(new URL("http://127.0.0.1:4723/wd/hub"), cap);
        } catch (MalformedURLException e) {
            e.printStackTrace();
        }   <--- this is line 50


Jonathan Lipps

unread,
Feb 12, 2014, 7:40:07 PM2/12/14
to Ravid Te, appium-...@googlegroups.com
you're saying the error is thrown before the first .get command?

Ravid Te

unread,
Feb 12, 2014, 7:53:00 PM2/12/14
to Jonathan Lipps, appium-...@googlegroups.com
Hey Jonathan,

My mistake, please ignore the stacktrace above.
I had made changes which led to that error output.
I reverted things back to how they were originally and no output is seen in the console like before, it just says terminated.

Sorry for the confusion.

With that said, any ideas on the empty params for the 2nd get() call to bing?

~Ravid


Jonathan Lipps

unread,
Feb 12, 2014, 8:09:02 PM2/12/14
to Ravid Te, appium-...@googlegroups.com
What i'm saying is the empty params aren't coming from the 2nd get() call to bing. that call is never making it to the appium server. Instead, some other call is coming in from the outside--a quit() call. It is probably buried in your test framework somewhere.

Ravid Te

unread,
Feb 12, 2014, 8:29:57 PM2/12/14
to Jonathan Lipps, appium-...@googlegroups.com
Hey Jonathan,

Eureka !! ... as they say.  I went the bare bones approach and removed the test framework. I was using (junit 4.10), and low and behold, I was able to navigate find from google to bing to cnn albeit very slow with ARM.
Below is the simple java application I created that worked:

public class AppiumTester {
  public static void main(String[] args) throws MalformedURLException {
  WebDriver driver = null;


  DesiredCapabilities cap = new DesiredCapabilities();

  cap.setCapability("device", "Android");
  cap.setCapability("app", "chrome");
  driver = new RemoteWebDriver(new URL("http://127.0.0.1:4723/wd/hub"), cap);
  driver.get("http://www.google.com");
  driver.get("http://www.bing.com");

  driver.get("http://www.cnn.com");
  driver.quit();
  }
}

The environment again that I confirmed this working:

OS: OSX 10.9.1
Android Emulator:  4.3 API Level 18
          CPU: ARM 
Appium: v0.15.0 
Chrome driver: v2.9
          Chrome browser: 32.0.1700.99 


Hopefully this helps others, 

Thanks again for your help Jonathan !

Cheers!!
~Ravid



Lew Bloch

unread,
Feb 12, 2014, 8:58:47 PM2/12/14
to appium-...@googlegroups.com
Ravid Te wrote:
... low and behold,
 
"lo and behold"

BTW, I'm new to Appium and liking it a lot. I do have a code comment re:

public class AppiumTester {
  public static void main(String[] args) throws MalformedURLException {
  WebDriver driver = null;


  DesiredCapabilities cap = new DesiredCapabilities();
  cap.setCapability("device", "Android");
  cap.setCapability("app", "chrome");
  driver = new RemoteWebDriver(new URL("http://127.0.0.1:4723/wd/hub"), cap);
  driver.get("http://www.google.com");
  driver.get("http://www.bing.com");
  driver.get("http://www.cnn.com");
  driver.quit();
  }
}


You could eliminate the redundant initialization of 'driver = null' entirely. 
Better yet, you could initialize it to the instantiation of 'new RemoteWebDriver(...)'.

See Joshua Bloch's _Effective Java_ (latest edition) for advice, Item 45, Minimize the scope of local variables:
"The most powerful technique for minimizing the scope of a local variable is to declare it where it is first used. 
If a variable is declared before it is used, it's just clutter--one more thing to distract the reader who is trying to 
figure out what the program does. By the time the variable is used, the reader might not remember the 
variable's type or initial value."

-- 
Lew

Ravid Te

unread,
Feb 12, 2014, 9:32:42 PM2/12/14
to Lew Bloch, appium-...@googlegroups.com
Hey Lew,

Thanks for the correction, always thought it was low and behold :).

Yep, although it was just test code, you are correct, I should be more mindful of messy unreadable code.
Will keep this in mind for the next time.

Cheers,
~Ravid


--
http://appium.io
---
You received this message because you are subscribed to a topic in the Google Groups "Appium-discuss" group.
To unsubscribe from this topic, visit https://groups.google.com/d/topic/appium-discuss/IJGFz-MzfMY/unsubscribe.
To unsubscribe from this group and all its topics, send an email to appium-discus...@googlegroups.com.
Reply all
Reply to author
Forward
0 new messages