0

I'm trying to set a remote PC as a Selenium node, using a console app that will run on the hub/server PC.

When the program's run in debug mode, I get the following text in 'errorMessage'

The handle is invalid.
Connecting to 200.200.20.200:5555...
Couldn't access 200.200.20.200:5555
Connecting to 200.200.20.200:5555...

The server has PsExec at : D:\PSTools\PsExec.exe
Server IP : 100.100.10.100
Remote IP : 200.200.20.200
The jar file in remote PC is saved at : D:\Selenium\selenium-server-standalone.jar

The command to be run in remote pc is

D:\Selenium>java -jar selenium-server-standalone.jar -role node -hub http://100.100.10.100/grid/register  

what am i missing here

private static void StartSeleniumNode()
        {
            Process p = new Process();
            p.StartInfo.UseShellExecute = false;
            p.StartInfo.RedirectStandardOutput = true;
            p.StartInfo.RedirectStandardError = true;
            p.StartInfo.RedirectStandardInput = true;
            p.StartInfo.FileName = @"D:\PSTools\PsExec.exe";
            p.StartInfo.Arguments = @"\\200.200.20.200:5555 -u xyz -p abc123 -i -w D:\Selenium java -jar selenium-server-standalone.jar -role node -hub http://100.100.10.100:4444/grid/register";
            p.Start();

            string output = p.StandardOutput.ReadToEnd();
            string errormessage = p.StandardError.ReadToEnd();

            p.WaitForExit();
        }
sukesh
  • 2,379
  • 12
  • 56
  • 111
  • When I manually run commands to setup the hub & nodes in the respective computers, it works – sukesh Aug 19 '15 at 09:59

1 Answers1

1

You should be able to piece this out yourself

You've given us: p.StartInfo.Arguments = @"\\200.200.20.200"; \\what should go here

Well you have the command you want to run

java -jar selenium-server-standalone.jar -role node -hub http://100.100.10.100/grid/register

You know the PC you want to run it on.. You have psexec to get the parameters of what you need to send it.

So, it would go something like

D:\PSTools\PsExec.exe psexec \\remotepc -i -w D:\Selenium java -jar selenium-server-standalone.jar -role node -hub http://100.100.10.100/grid/register

Try running that from your command line and when you get the command line working. You are ready to code it (Lets just assume that works.)

Your code would then be

p.StartInfo.FileName = @"D:\PSTools\PsExec.exe";
p.StartInfo.Arguments = @"\\remotepc -i -w D:\Selenium java -jar selenium-server-standalone.jar -role node -hub http://100.100.10.100/grid/register"; 
BugFinder
  • 17,474
  • 4
  • 36
  • 51
  • For the sake of completeness, the usage of PsExec is documented quite good [on its download page at Microsoft](https://technet.microsoft.com/en-us/sysinternals/bb897553.aspx) – KeyNone Aug 19 '15 at 10:07
  • 1
    Yes it is.. although psexec is banned where I work, so I made my own :D out of c# of course – BugFinder Aug 19 '15 at 10:13
  • Just tried and the 'errorMessage' says Couldn't access 200.200.20.200:. Is it essential to pass the remote pc's credentials – sukesh Aug 19 '15 at 10:16
  • You would have to check the other end, what it tried to log in as, if it tried as guest.. then you may need to add the credentials, normally of course it runs as the current user.. if that doesnt have rights, but then you said you had a working command line.. – BugFinder Aug 19 '15 at 10:21
  • I have tried with credentials. The errorMessage still says couldn't access – sukesh Aug 19 '15 at 11:29
  • I cant really help you with that.. mine worked.. What are you seeing the other end – BugFinder Aug 19 '15 at 11:34
  • Could you plz tell me what & how shoudl I be checking at the other end – sukesh Aug 19 '15 at 11:36
  • What the remote server is saying when your user is trying to login - after all, its whats saying no – BugFinder Aug 19 '15 at 11:39
  • The issue seems to be with order of params in Arguments and I am able to connect manually now. But plz tell me, is it necessary to have psexec running in the node too? – sukesh Aug 19 '15 at 12:36
  • To be honest, you arent making a huge amount of sense to me - if you have a working command line that command line should be all you need to put in. – BugFinder Aug 19 '15 at 12:44