Selenium WebDriver在IE浏览器的文本字段中键入非常慢

TDH*_*DHM 54 selenium internet-explorer selenium-webdriver

我正在IE 11浏览器上运行我的一个脚本,Selenium 2.43.1 当脚本在文本字段中键入时使用以下内容:

element.sendKeys("string");
Run Code Online (Sandbox Code Playgroud)

在IE浏览器中,我可以看到字符串中的一个字符在文本字段中键入,并且在键入下一个字符之前等待1-2秒.键入一个字符的方法需要1-2秒.

  1. 为什么用IE输入这么慢?
  2. 有没有其他方法可以加快打字速度?

Mas*_*ave 50

我的问题在于驱动程序架构,并通过下载和使用32位解决方案来修复它.

要切换到32位,这就是你需要做的

  1. http://selenium-release.storage.googleapis.com/index.html下载32位驱动程序服务
  2. InterExplorerWeDriver使用InternetExplorerDriverService具有32位驱动程序服务路径的类来实例化您的类 .

    InternetExplorerDriver ieDiver = new InternetExplorerDriver(“Path to the 32 bit Explorer driver”);

或者如果使用构建器:

System.setProperty(“webdriver.ie.driver”,“C:\\drivers\\IEDriverServer.exe”);
DesiredCapabilities ieCapabilities=DesiredCapabilities.internetExplorer();
ieCapabilities.setCapability(InternetExplorerDriver
 .INTRODUCE_FLAKINESS_BY_IGNORING_SECURITY_DOMAINS,true);
ieCapabilities.setCapability("requireWindowFocus", true);
File ie_temp=newFile(“C:\\Selenium\\IEDrivertemp”);
InternetExplorerDriverService.Builder 
ies=newInternetExplorerDriverService.Builder();
ies.withExtractPath(ie_temp);
InternetExplorerDriverService service=ies.build();
WebDriver driver=newInternetExplorerDriver(service,ieCapabilities))
Run Code Online (Sandbox Code Playgroud)

帮助我解决的线索

http://forumsqa.com/question/typing-too-slow-in-text-fields-while-replaying-tests/

  • 我在64位Windows机器上,所以我想"我为什么要使用32位WebDriver?" 但后来我检查了; 瞧,我的64位机器配备32位Internet Explorer.这个答案 - 尽管我最初忽视它 - 是唯一有效的方法.您可以在http://www.seleniumhq.org/download/下载IEDriverServer.exe (3认同)

小智 32

对我来说,它适用于64位版本的IEDriverServer.我添加了属性requireWindowFocus"true"值:

DesiredCapabilities capabilities = DesiredCapabilities.internetExplorer();
capabilities.setCapability(InternetExplorerDriver.INTRODUCE_FLAKINESS_BY_IGNORING_SECURITY_DOMAINS, true);
...
capabilities.setCapability("requireWindowFocus", true);
WebDriver driver = new InternetExplorerDriver(capabilities);
Run Code Online (Sandbox Code Playgroud)

我正在使用Selenium/IE驱动程序的2.47版本


Mar*_*cus 17

对于64位WebDriver:

  1. 打开IE
  2. 转到Internet选项→高级→安全性
  3. 检查☑为增强保护模式启用64位进程
  4. 单击"应用"和"确定

对于32位WebDriver:

  1. 打开IE
  2. 转到Internet选项→高级→安全性
  3. 取消选中☐为增强保护模式启用64位进程
  4. 单击"应用"和"确定

奇怪的是:

  • 无论是否激活增强保护模式,该设置都是必要的.
  • 除了在对话框中显示的文本之外,没有必要重新启动计算机.

我的设置:Windows 10,IE 11,64位,Selenium 3.4


Dem*_*ave 11

这有点让我加快了速度.IEDriverServer 2.53.1

InternetExplorerOptions options = new InternetExplorerOptions();
options.IntroduceInstabilityByIgnoringProtectedModeSettings = true;
options.RequireWindowFocus = true;
driver = new InternetExplorerDriver(options);
Run Code Online (Sandbox Code Playgroud)


小智 6

您可以更改为32位版本,但如果需要64位,则可以尝试此解决方案:

  • Internet选项 - >安全性 - >检查所有区域的"启用保护模式"
  • 转到高级 - >安全 - >选中"启用增强保护模式"

这导致在64位IE上不再输入蜗牛.