Selenium远程Web驱动程序:如何确定使用哪个IEDriverServer.exe(32位或64位)?

时间:2015-06-23 17:41:50

标签: python internet-explorer selenium selenium-webdriver

我通过其一方的Python绑定使用Selenium,另一方面通过Selenium独立服务器。这是我正在使用的服务器命令行:

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 个答案:

答案 0 :(得分:1)

我不确定,我们有选择使用Selenium进行检查。可以做的是使用Browser对象,我们可以选择Title并将其映射到机器上运行的进程。 我编写了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

希望这对你有所帮助。