Selenium Forum: Functional And Regression Testing Tool.
Would you like to react to this message? Create an account in a few clicks or log in to continue.
Search
Display results as :
Advanced Search
Latest topics
AEM Training | Free Online DemoWed Apr 21, 2021 5:45 pmazharuddin
c# PageFactory - issue initializing elementsFri Nov 01, 2019 8:40 pmthegoatboy
Selenium making automatic connection to random urlsMon Jul 08, 2019 12:58 pmrepairtechsolutions1
How can we design the custom framework in Selenium RCMon Jun 24, 2019 2:26 pmrandybonnettes
What are the new features in Selenium 3.0Tue Jun 18, 2019 5:37 pmpappyvicky
What are you using Selenium for? Fri Apr 12, 2019 3:52 amzhl
LIMITATIONS OF SELENIUMWed Apr 10, 2019 11:23 amswara
Navigation
 Portal
 Index
 Memberlist
 Profile
 FAQ
 Search

Go down
avatar
JeffNigl
Posts : 2
Join date : 2012-02-16

Script Execution using AndroidDriver Empty Script Execution using AndroidDriver

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 = DesiredCapabilities.android();
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" + "://" + "google.com");
Thread.sleep(15000);
Object result = ((JavascriptExecutor) driver).executeScript("return window.location.href;");
System.out.println("result: " + result.toString());
driver.quit();
}
}


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: os.name: '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(RemoteWebDriver.java:412)
at org.openqa.selenium.remote.RemoteWebDriver.executeScript(RemoteWebDriver.java:332)
at Testing.main(Testing.java:25)
Caused by: org.apache.http.NoHttpResponseException: The target server failed to respond
at org.apache.http.impl.conn.DefaultResponseParser.parseHead(DefaultResponseParser.java:101)
at org.apache.http.impl.io.AbstractMessageParser.parse(AbstractMessageParser.java:252)
at org.apache.http.impl.AbstractHttpClientConnection.receiveResponseHeader(AbstractHttpClientConnection.java:281)
at org.apache.http.impl.conn.DefaultClientConnection.receiveResponseHeader(DefaultClientConnection.java:247)
at org.apache.http.impl.conn.AbstractClientConnAdapter.receiveResponseHeader(AbstractClientConnAdapter.java:219)
at org.apache.http.protocol.HttpRequestExecutor.doReceiveResponse(HttpRequestExecutor.java:298)
at org.apache.http.protocol.HttpRequestExecutor.execute(HttpRequestExecutor.java:125)
at org.apache.http.impl.client.DefaultRequestDirector.tryExecute(DefaultRequestDirector.java:645)
at org.apache.http.impl.client.DefaultRequestDirector.execute(DefaultRequestDirector.java:464)
at org.apache.http.impl.client.AbstractHttpClient.execute(AbstractHttpClient.java:820)
at org.openqa.selenium.remote.HttpCommandExecutor.fallBackExecute(HttpCommandExecutor.java:410)
at org.openqa.selenium.remote.HttpCommandExecutor.execute(HttpCommandExecutor.java:371)
at org.openqa.selenium.remote.RemoteWebDriver.execute(RemoteWebDriver.java:398)
... 2 more
avatar
JeffNigl
Posts : 2
Join date : 2012-02-16

Script Execution using AndroidDriver Empty Re: Script Execution using AndroidDriver

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.

Thanks
Back to top
Permissions in this forum:
You cannot reply to topics in this forum