我发布了自动化项目并发送到主机服务器。当我尝试从网络上获取它时,我在页面上收到了此错误;
FireFox executable listed in the registry does not exist, please make sure you have installed FireFox correctly
经过几次搜索后,我发现了这个并添加了我的代码
DesiredCapabilities capability = DesiredCapabilities.Firefox();
capability.SetCapability("platform", Platform.CurrentPlatform);
capability.SetCapability("binary", "C:\\Program Files (x86)\\Mozilla Firefox\\msfirefox.exe");
IWebDriver driver = new RemoteWebDriver(new Uri("http://localhost:4444/wd/hub"), capability);
现在我在页面上收到此错误;
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:4444
at System.Net.Sockets.Socket.DoConnect(EndPoint endPointSnapshot, SocketAddress socketAddress)
at System.Net.ServicePoint.ConnectSocketInternal(Boolean connectFailure, Socket s4, Socket s6, Socket& socket, IPAddress& address, ConnectSocketState state, IAsyncResult asyncResult, 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)
我在这里有点困惑,我不能在服务器上运行它吗?
答案 0 :(得分:1)
问题可能是您尝试访问的网址。 http://localhost:4444/wd/hub
指的是当前计算机的4444端口,这意味着如果您在开发人员计算机上访问该页面,它就会触及您的开发人员计算机。如果您在服务器上访问它,它会命中服务器。你在服务器上运行/wd/hub
吗?