无法初始化AndroidDriver

时间:2012-10-04 16:50:21

标签: c# selenium android-emulator webdriver selenium-webdriver

在W2k8 64位我在Android 4.1仿真器实例中安装了ARM 4.1 API Level 16。 启动后,我正在运行我的UnitTest并在第一行

 var webDriver = new AndroidDriver("http://localhost:8080/wd/hub"); //also with no argument

我有一个例外:

Unexpected error. System.Net.WebException: Unable to connect to the remote server ---> System.Net.Sockets.SocketException: No connection could be made because the target machine actively refused it 127.0.0.1:8080
   at System.Net.Sockets.Socket.DoConnect(EndPoint endPointSnapshot, SocketAddress socketAddress)
   at System.Net.Sockets.Socket.InternalConnect(EndPoint remoteEP)
   at System.Net.ServicePoint.ConnectSocketInternal(Boolean connectFailure, Socket s4, Socket s6, Socket& socket, IPAddress& address, ConnectSocketState state, IAsyncResult asyncResult, Int32 timeout, Exception& exception)
   --- End of inner exception stack trace ---
   at System.Net.HttpWebRequest.GetRequestStream(TransportContext& context)
   at System.Net.HttpWebRequest.GetRequestStream()
   at OpenQA.Selenium.Remote.HttpCommandExecutor.Execute(Command commandToExecute)
   at OpenQA.Selenium.Remote.RemoteWebDriver.Execute(String driverCommandToExecute, Dictionary`2 parameters)

此WebDriver的版本为2.25.1.0。

我遵循了这篇文章:

http://www.nishantverma.com/2011/06/installing-webdriver-on-android.html

当我使用其他驱动程序(如Firefox-或ChromeDriver)时效果很好。

我会感激任何建议

2 个答案:

答案 0 :(得分:1)

我可能会告诉你你已经知道的内容,但是你启动了tcp端口转发到你正在运行的android服务器。供参考检查 Android Driver

答案 1 :(得分:0)

由于某种原因,您的服务器无法启动。你可能已经在端口8080上运行了其他东西吗?

尝试运行netstat -a -n并查看是否列出了端口8080。

如果正在使用,您可以尝试在其他端口上设置或终止正在使用该端口的进程。

您也可以尝试在您的计算机上禁用UAC和防火墙和/或以管理员身份运行该过程,看看是否有帮助(这当然是暂时的,不要将其关闭)。

相关问题