2015-06-23 14 views
1

我使用硒通過一側的Python綁定,並通過在另一側的硒獨立服務器。下面是我使用的服務器的命令行:硒遠程Web司機:我如何確定哪些(32位或64位)正在使用IEDriverServer.exe?

java -jar selenium-server-standalone-2.46.0.jar -Dwebdriver.ie.driver=IEDriverServer.exe 

的IEDriverServer.exe有兩種形式:32位和64位。有一個衆所周知的錯誤,使用64位版本會導致測試執行速度非常慢。例如,發送文本到編輯框時,每發送一個字符需要4或5秒。解決方案是使用32位驅動程序,即使在64位Windows上也是如此。

當我與32位版本上運行,我認爲這在服務器輸出,當我創建一個IE瀏覽器實例:

Started InternetExplorerDriver server (32-bit) 

不過,我似乎無法找到一個方法來確定哪些版本從客戶端運行。它不會像IE版本那樣在功能中返回。

我怎麼能確定哪個驅動程序從客戶端運行?

謝謝。

回答

1

我不確定,我們有選擇使用Selenium進行檢查。可以做的是使用瀏覽器對象,我們可以選擇標題並將其與機器上運行的進程映射。 我寫了C#代碼來打印瀏覽器路徑(EXE),通過它我們可以確定瀏覽器是32位還是64位。

public static void PrintBrowserDetails() 
    { 
     string procName = "iexplore"; 

     foreach (System.Diagnostics.Process proc in System.Diagnostics.Process.GetProcessesByName(procName)) 
     { 
      if (!string.IsNullOrEmpty(proc.MainWindowTitle)) 
      { 
       if (proc.MainWindowTitle.Contains(Util.Browser.Title)) 
       { 
        System.Diagnostics.ProcessModuleCollection prm = proc.Modules; 
        foreach (System.Diagnostics.ProcessModule pm in prm) 
        { 
         if (pm.ModuleName.Contains("IEXPLORE.EXE")) 
         { 
          System.Diagnostics.FileVersionInfo fi = pm.FileVersionInfo; 
          Console.WriteLine(fi.FileName); // Output: C:\Program Files (x86)\Internet Explorer\IEXPLORE.EXE 
          Console.WriteLine(fi.FileVersion); // Output: 8.0.7601.17514 
          Console.WriteLine(fi.FileDescription); // Internet Explorer. 
         } 
        } 
       } 
      } 
     } 
    } 
    // Util.Browser -> Selenium Browser object 

希望這可以幫助你。