通过C#运行selenium时出错

时间:2011-07-20 16:22:37

标签: c# selenium

尝试使用此代码运行selenium套件,该代码在我的本地计算机上运行完美,但在部署在服务器上时发出错误,说无法找到指定的文件。任何帮助将不胜感激?

程序和论点:

  

program =“java”;
  Arguments =“-jar selenium-server.jar和参数的其余部分,如selenium v​​中给出浏览器端口和结果以及testcase文件”;

    standardErr = String.Empty;
    standardOut = String.Empty;

    if (!silent)
    {
        Console.WriteLine("start" + program + " " + arguments);
    }

    Process proc = Process.GetCurrentProcess();
    proc.StartInfo.Arguments = arguments;

    if (!string.IsNullOrEmpty(workingDirectory))
    {
        //execute from the specific working directory if specified
        proc.StartInfo.WorkingDirectory = workingDirectory;
    }

    proc.EnableRaisingEvents = true;
    proc.StartInfo.FileName = program;
    proc.StartInfo.CreateNoWindow = true;
    proc.StartInfo.UseShellExecute = false;
    proc.StartInfo.RedirectStandardOutput = true;
    proc.StartInfo.RedirectStandardError = true;
    proc.Start();
    proc.WaitForExit();

    if (!silent)
    {
        if (proc.StandardOutput != null)
        {
            standardOut = proc.StandardOutput.ReadToEnd();
            Console.WriteLine(standardOut);
        }
    }

    if (proc.StandardError != null)
    {
        standardErr = proc.StandardError.ReadToEnd();
        Console.WriteLine(standardErr);
    }

    proc.StandardOutput.Close();
    proc.StandardError.Close();
    return standardErr;

1 个答案:

答案 0 :(得分:1)

确保本地计算机和服务器具有相同的环境设置(路径,类路径等)

接下来(如果问题仍然存在)尝试找出无法找到的文件(Eventlog,其他日志)