简体   繁体   中英

Running firefox Selenium driver on Hosting Server c#

I published my automation project and send to host server. When I try to reach it from web first I got this error on page ;

 FireFox executable listed in the registry does not exist, please make sure you have installed FireFox correctly

after a few search I find this and add my code

 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);

now I am getting this error on page ;

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)

I am a bit confused here, can't I run it in server or not ?

The issue is probably the URL you are trying to hit. http://localhost:4444/wd/hub refers to the current machine's 4444 port, that means if you access that page on your developer machine, it hits your developer machine. If you access it on the server, it hits the server. Do you have /wd/hub running on the server?

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM