View previous topicGo downView next topic
Posts : 2
Join date : 2012-02-16

Script Execution using AndroidDriver

on Thu Feb 16, 2012 5:25 am
Hey Everyone,

I'm trying to setup a java-based mobile web driver using AndroidDriver, but I'm having trouble executing scripts against the Android SDK emulator. I've installed the android-server-2.13.0.apk on to the device and I'm using Selenium 2.13.0 (I'm not sure if the versions have to match or not, but they do). I'm able to navigate to any web page, but am not able to run javascript scripts using the JavascriptExecutor. When it gets to the line that attempts to run the script, WebDriver on the emulator closes (or dies) and an exception is thrown. You can see the code (yes, the url in the code looks funny, but it wouldn't let me add this post without it since I'm new) and exception below. When I switch the web driver to FirefoxDriver, or InternetExplorerDriver, it works just fine.

Thanks in advance,

public class Testing {
public static void main(String[] args) throws Exception {
DesiredCapabilities caps =;
caps.setCapability(CapabilityType.SUPPORTS_JAVASCRIPT, true);
WebDriver driver = new AndroidDriver(caps);
driver.manage().timeouts().implicitlyWait(10000, TimeUnit.MILLISECONDS);
driver.manage().timeouts().setScriptTimeout(10000, TimeUnit.MILLISECONDS);
driver.navigate().to("http" + "://" + "");
Object result = ((JavascriptExecutor) driver).executeScript("return window.location.href;");
System.out.println("result: " + result.toString());

Exception in thread "main" org.openqa.selenium.WebDriverException: Error communicating with the remote browser. It may have died.
Build info: version: '2.13.0', revision: '14793', time: '2011-11-18 13:17:03'
System info: 'Windows 7', os.arch: 'amd64', os.version: '6.1', java.version: '1.6.0_26'
Driver info: driver.version: RemoteWebDriver
at org.openqa.selenium.remote.RemoteWebDriver.execute(
at org.openqa.selenium.remote.RemoteWebDriver.executeScript(
at Testing.main(
Caused by: org.apache.http.NoHttpResponseException: The target server failed to respond
at org.apache.http.impl.conn.DefaultResponseParser.parseHead(
at org.apache.http.impl.AbstractHttpClientConnection.receiveResponseHeader(
at org.apache.http.impl.conn.DefaultClientConnection.receiveResponseHeader(
at org.apache.http.impl.conn.AbstractClientConnAdapter.receiveResponseHeader(
at org.apache.http.protocol.HttpRequestExecutor.doReceiveResponse(
at org.apache.http.protocol.HttpRequestExecutor.execute(
at org.apache.http.impl.client.DefaultRequestDirector.tryExecute(
at org.apache.http.impl.client.DefaultRequestDirector.execute(
at org.apache.http.impl.client.AbstractHttpClient.execute(
at org.openqa.selenium.remote.HttpCommandExecutor.fallBackExecute(
at org.openqa.selenium.remote.HttpCommandExecutor.execute(
at org.openqa.selenium.remote.RemoteWebDriver.execute(
... 2 more
Posts : 2
Join date : 2012-02-16

Re: Script Execution using AndroidDriver

on Fri Feb 17, 2012 4:11 am
Apparently, this is a known bug for android 2. Everything works fine when I switched to android 4.

View previous topicBack to topView next topic
Permissions in this forum:
You cannot reply to topics in this forum