gpt4 book ai didi

python - 正在使用 Selenium 远程 Web 驱动程序 : How do I determine which IEDriverServer. exe(32 位或 64 位)?

转载 作者:太空宇宙 更新时间:2023-11-04 05:49:18 25 4
gpt4 key购买 nike

我一方面通过其 Python 绑定(bind)使用 Selenium,另一方面通过 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 版本那样在功能中返回。

如何从客户端确定正在运行的驱动程序?

谢谢。

最佳答案

我不确定,我们可以选择使用 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

希望这对你有帮助。

关于python - 正在使用 Selenium 远程 Web 驱动程序 : How do I determine which IEDriverServer. exe(32 位或 64 位)?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/31009770/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com