0

I can't get Selenium grid working. I've included screen shots below to help. Can anyone see what's wrong? I've almost given up, looking at tutorials/ articles/ videos out there what I've tried below should work but it doesn't. Can anyone advise? Thanks

Update

Watch the problem in this short youtube video https://www.youtube.com/watch?v=zhWhhDnR1Bg

Server jar file location

Selenium server standalone location

Command to start the selenium server

starting the server

After starting the server

C# exception

Question update

An exception of type 'OpenQA.Selenium.WebDriverException' occurred in WebDriver.dll but was not handled in user code

Additional information: Unexpected error. System.Net.WebException: Unable to connect to the remote server ---> System.Net.Sockets.SocketException: The requested address is not valid in its context 0.0.0.0: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)

New Console application

Executing this new code after starting the selenium hub and node throws an exception:

static void Main(string[] args)
{
    var url = new Uri("http://10.6.122.49:4444/wd/hub");

    var driver = new RemoteWebDriver(url, new FirefoxOptions());  // This line throws an exception

    driver.Navigate().GoToUrl("http://www.google.com");

 }

Have tried the following although the error still happens

Environment.SetEnvironmentVariable("webdriver.gecko.driver", @"D:\geckodriver.exe");

After trying the curl command

$ curl -i -H "Accept: application/json" -X POST -d '{"desiredCapabilities":{"bro % Total % Received % Xferd Average Speed Time Time Time Current Dload Upload Total Spent Left Speed 0 0 0 0 0 0 0 0 --:--:-- --:--:-- --:--:-- 0HT Date: Fri, 29 Sep 2017 15:27:00 GMT Expires: Thu, 01 Jan 1970 00:00:00 GMT Cache-Control: no-cache Content-Type: application/json;charset=utf-8 Server: Jetty(9.4.3.v20170317) Content-Length: 5374

{"state":"unknown error","sessionId":null,"hCode":11474323,"value":{"localizedMee downloaded from https://github.com/mozilla/geckodriver/releases","cause":null,java.lang.StackTraceElement"},{"fileName":"DriverService.java","nativeMethod":faDriverService.java","nativeMethod":false,"methodName":"access$100","className":"":"findDefaultExecutable","className":"org.openqa.selenium.firefox.GeckoDriverSelenium.remote.service.DriverService$Builder","hCode":778286220,"lineNumber":330,44,"lineNumber":207,"class":"java.lang.StackTraceElement"},{"fileName":"FirefoxDeName":"FirefoxDriver.java","nativeMethod":false,"methodName":"","classNamssName":"sun.reflect.NativeConstructorAccessorImpl","hCode":513928194,"lineNumbeumber":-1,"class":"java.lang.StackTraceElement"},{"fileName":null,"nativeMethod"veMethod":false,"methodName":"newInstance","className":"java.lang.reflect.Constr.openqa.selenium.remote.server.FirefoxDriverProvider","hCode":380089702,"lineNumriverProvider","hCode":-616843603,"lineNumber":63,"class":"java.lang.StackTraceENumber":60,"class":"java.lang.StackTraceElement"},{"fileName":"DefaultSession.ja100 5423 100 5374 100 49 42992 392 --:--:-- --:--:-- --:--:-- 48854med":false,"methodName":"run","className":"java.util.concurrent.FutureTask","hCodeaultSession$1","hCode":-255143467,"lineNumber":176,"class":"java.lang.StackTraceeElement"},{"fileName":null,"nativeMethod":false,"methodName":"run","className"::"java.lang.Thread","hCode":1432591020,"lineNumber":-1,"class":"java.lang.StackTkodriver. The latest version can be downloaded from https://github.com/mozilla/g

user7558986
  • 65
  • 2
  • 8
  • 1
    Try to add text instead of images, also for running on specific browser you need to specify the driver. Why do you need grid? If you only use one browser you can use the same selenium server for parallel run without any specific setting. See here how to start it https://stackoverflow.com/questions/42032960/unknown-option-dwebdriver-chrome-driver-when-running-selenium-server-standalon – lauda Aug 24 '17 at 13:53
  • This is just an early version, obviously I want to expand it to use multiple systems/ browsers etc. – user7558986 Aug 24 '17 at 13:55
  • Try using `127.0.0.1` or `0.0.0.0` instead of `localhost` and see if it works. Sometimes firewall may be active and causing the issue – Tarun Lalwani Aug 24 '17 at 14:05
  • I've changed the address to 0.0.0.0 and I receive the following (see question update) – user7558986 Aug 24 '17 at 14:39
  • Did you start the node as well? isn't that required? – so cal cheesehead Aug 24 '17 at 15:21
  • think I have? When i'm trying this I have launched this command in a separate command prompt "java -jar selenium-server-standalone-3.4.0.jar -role node -hub http://localhost:4444/grid/regster – user7558986 Aug 24 '17 at 15:30

1 Answers1

0

The error The requested address is not valid in its context is indicating that the IP address is perhaps invalid. I found that from The requested address is not valid in its context when i try to listen a port

In your command prompt wherein you started the hub, you would notice a line like this Nodes should register to http://10.6.122.49:4444.

In your tests you can try instantiating a RemoteWebDriver with the IP 10.6.122.49 instead of localhost.

And I am hoping that you have started the node and had it register itself to the hub.

On some machines (especially in the MAC) I have noticed that at times localhost doesn't work and you would need to add your machine name as well to the /etc/hosts file [ This may or may not be applicable to your issue ]

I would also suggest that you take a look at this Tutorial (or book, you can call it whatever you want) that I created, which helps you get oriented with the Grid and its setup apart from a lot of other things which you would like to know about the Grid. See here

Krishnan Mahadevan
  • 14,121
  • 6
  • 34
  • 66
  • thanks for the comment, can you provide step by step instructions please. – user7558986 Aug 29 '17 at 13:39
  • @user7558986 - What step by step instructions are you looking for ? I didn't quite understand. – Krishnan Mahadevan Aug 29 '17 at 13:42
  • How to get it working please. I've created a new C# console application with the code included in my question (see New Console application heading). When I run the code (hitting F5 within visual studio) the "var drfiver = ..." line throws an exception "An unhandled exception of type 'System.InvalidOperationException' occurred in WebDriver.dll" – user7558986 Aug 29 '17 at 13:54
  • Tutorials seems to suggest to use System.setProperty("firefox path") but when trying the System.setProperty the method is not available within C# using Selenium 3.4 ???? – user7558986 Aug 29 '17 at 15:17
  • Thanks for that but I've already tried it. I've updated the question above – user7558986 Aug 29 '17 at 16:01
  • @user7558986 - I think we are going around in circles. Setting the system property is NOT going to work when dealing with a selenium grid. In the Selenium Grid scenario, you would need to use pass JVM arguments via `-D`. I would suggest that you first get a Selenium Grid/node setup up and running by reading through the Tutorial link that I shared. Once you have that up and running, then try to first ensure that the console URL gets loaded from the machine on which you are running your C# code. – Krishnan Mahadevan Aug 29 '17 at 16:06
  • yes I know, so please give me clear instructions. I've followed your article and it doesn't work – user7558986 Aug 30 '17 at 08:35
  • @user7558986 - I didn't quite understand what do you mean by `Run I F5`? What do you mean ? Have you setup the grid properly ? What happens when you use a tool such as postman for e.g., or a curl command `curl -i -H "Accept: application/json" -X POST -d '{"desiredCapabilities":{"browserName":"firefox"}}' http://localhost:4444/wd/hub/session` If this works, then the grid setup works fine. – Krishnan Mahadevan Aug 30 '17 at 09:51
  • I have filmed it for you. Please watch this https://www.youtube.com/watch?v=zhWhhDnR1Bg – user7558986 Aug 30 '17 at 10:11
  • I watched the video. I am still saying the same thing that I have been saying. Please start the Hub and the node. Then run the curl command that I shared earlier to check if there are no network blockages etc., (it looks like you have something blocking). If the curl command runs properly (run it from the machine, from where u are running ur selenium tests) then it means that network issues can be ruled out. Am afraid I don't have anything more to offer, till this part is sorted out by you. – Krishnan Mahadevan Aug 30 '17 at 14:11