0

Selenium テストを実行するために CCNET サーバーをセットアップしています。テスト コードでは、次のコマンドを使用して、Selenium RC サーバーが実行されていない場合に起動します。

var proc = new Process();
proc.StartInfo.WorkingDirectory = Path.Combine(Directory.GetParent(Assembly.GetExecutingAssembly().Location).FullName, @"..\..\..\..\..\lib\SeleniumRC\selenium-server-1.0-beta-2");
proc.StartInfo.FileName = "java"; //have also tried with "java.exe"
proc.StartInfo.Arguments = @"-jar selenium-server.jar -multiWindow -trustAllSSLCertificates -firefoxProfileTemplate ""..\Firefox Profiles\Relaxed Security""";
proc.StartInfo.UseShellExecute = true;
proc.Start();

これは私の開発マシンでうまく機能します。ただし、CCNET.exe から (ユーザー コンテキストで) 実行すると、java.exe プロセスを実行する代わりに、"c:\windows\java" のエクスプローラ ウィンドウが表示されます。パスの設定が間違っていると思いますが、方法がわかりません。手伝ってくれますか?

4

4 に答える 4

2

バックグラウンドでサーバーを起動するためにこれを行いました:

// Start the java server
Process seleniumServer;
String javaFileLocation = @"C:\Program Files\Java\jre6\bin\java.exe";
String jarFileLocation = @"C:\SeleniumRC\selenium-remote-control-1.0.1\selenium-server-1.0.1\selenium-server.jar";
seleniumServer = new Process();
seleniumServer.StartInfo.FileName = javaFileLocation;
seleniumServer.StartInfo.Arguments = "-jar " + jarFileLocation;
seleniumServer.StartInfo.WorkingDirectory = jarFileLocation.Substring(0, jarFileLocation.LastIndexOf("\\"));
seleniumServer.StartInfo.UseShellExecute = true;
seleniumServer.StartInfo.WindowStyle = ProcessWindowStyle.Hidden;
seleniumServer.Start();

それからちょうどした

seleniumServer.Kill()

うまくいったからやめること。

これがCCNETの状況に役立つかどうかはわかりませんが、将来これを探している人々に役立つかもしれません?

于 2010-02-16T13:49:26.640 に答える
2

実行しているユーザー コンテキストのコマンド プロンプトでその作業ディレクトリに移動して、コマンド ラインを試してみましたか?

パスの設定が間違っている場合は、[マイ コンピューター]、[プロパティ]、[詳細設定]、[環境変数] を右クリックして調整できます。

于 2009-03-20T16:19:29.577 に答える
1

SeleniumProcess クラス

public class SeleniumProcess
    {
        private static Process _seleniumServer;

        public static void Start()
        {
            _seleniumServer = new Process
                                  {
                                      StartInfo =
                                          {
                                              FileName = "java",
                                              Arguments =
                                                  "-jar ../../../References/" +
                                                  "selenium-remote-control-1.0.3/" +
                                                  "selenium-server-1.0.3/" + "selenium-server.jar -port 4444"
                                          }
                                  };
            _seleniumServer.Start();
        }

        public static void Stop()
        {
            _seleniumServer.Kill();
        }
    }

リージョンのセットアップ/ティアダウン

    [SetUp]
    public void SetupTest()
    {
        SeleniumProcess.Start();
    }

    [TearDown]
    public void TeardownTest()
    {
        try
        {
            _selenium.Stop();
        }
        catch (Exception)
        {
            // Ignore errors if unable to close the browser
        }
        SeleniumProcess.Stop();
        Assert.AreEqual("", _verificationErrors.ToString());
    }

    #endregion
于 2010-03-05T13:19:54.810 に答える