0

我正在尝试使用将在集线器/服务器 PC 上运行的控制台应用程序将远程 PC 设置为 Selenium 节点。

当程序在调试模式下运行时,我在“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...

服务器有 PsExec 在:D:\PSTools\PsExec.exe
服务器 IP:100.100.10.100
远程 IP:200.200.20.200
远程 PC 中的 jar 文件保存在:D:\Selenium\selenium-server-standalone.jar

要在远程 pc 中运行的命令是

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

我在这里想念什么

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();
        }
4

1 回答 1

1

你应该能够自己解决这个问题

你给了我们:p.StartInfo.Arguments = @"\\200.200.20.200"; \\what should go here

那么你有你想要运行的命令

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

你知道你想在哪台电脑上运行它。你有 psexec 来获取你需要发送它的参数。

所以,它会像

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

尝试从命令行运行它,当你让命令行工作时。您已准备好对其进行编码(让我们假设它有效。)

您的代码将是

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"; 
于 2015-08-19T10:04:35.527 回答