Selenium Webdriver 测试期间的多个 Firefox 实例未正确处理焦点. [英] Multiple Instances of Firefox during Selenium Webdriver Testing not handling focus correctly.

查看:32
本文介绍了Selenium Webdriver 测试期间的多个 Firefox 实例未正确处理焦点.的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我注意到,在网格上并行运行多个 selenium firefox 测试时,焦点事件处理无法正常工作.我已经确认,当我的每个测试都单独运行并关注操作系统时,测试通过 100% 的时间.我还使用 Chrome 在网格上并行运行了测试,但没有发现问题.

I have noticed that while running multiple selenium firefox tests in parallel on a grid that the focus event handling is not working correctly. I have confirmed that when each of my tests is run individually and given focus of the OS the tests pass 100% of the time. I have also run the tests in parallel on the grid with Chrome and not seen the issue present.

我在 google 群组上发现了以下线程,该线程建议在单独的 xvfb 实例中启动每个浏览器可能是一个可行的解决方案.https://groups.google.com/forum/?fromgroups#!topic/selenium-developers/1cAmsYCp2ho%5B1-25%5D

I have found the following thread on google groups which suggests launching each browser in a separate instance of xvfb may be a viable solution. https://groups.google.com/forum/?fromgroups#!topic/selenium-developers/1cAmsYCp2ho%5B1-25%5D

测试失败的部分是由于项目中使用的 jquery 日期选择器.日期选择器在焦点事件上启动,并且由于同时执行多个 selenium 测试,所以 webdriver 测试执行 .click() 命令,但焦点没有保持足够长的时间以显示日期选择器小部件.

The portion of the test is failing is due to a jquery date picker which is used in the project. The date picker launches on a focus event and since there are multiple selenium tests executing at the same time the webdriver test executes the .click() command but focus does not remain long enough for the date picker widget to appear.

.focus(function(){ $input.trigger("focus"); });

.focus(function(){ $input.trigger("focus"); });

我的问题是,是否有人以前见过这个并通过一些 Firefox 配置文件设置解决了这个问题.我尝试加载以下对问题没有影响的属性.

My question is if anyone has seen this before and solved it through some firefox profile settings. I have tried loading the following property which had no affect on the issue.

profile.setAlwaysLoadNoFocusLib(true);

测试失败的方式与之前在远程驱动程序 Firefox 配置文件中启用并加载该属性的方式相同.

The test fails in the same way as it did before with that property enabled and loaded in the Remote Driver Firefox Profile.

我需要一种方法来确保 100% 的时间触发焦点事件或解决多个 Firefox 浏览器争夺焦点的问题.考虑到 Chrome 没有显示这些问题,我想知道它是否也可能被视为 Firefox 中的错误.

I need a way ensure the focus event is triggered 100% of the time or to solve the issue of multiple firefox browsers competing for focus. Considering Chrome displays none of these issues I wonder if it may also be considered a bug in firefox.

谢谢!

推荐答案

@djangofan:错了.您无法锁定焦点.在您在一个窗口中请求焦点并触发操作之前,另一个窗口请求焦点,并且您的操作(例如将键发送到输入字段)不起作用.这在我们的测试中每天都会发生几次.很难重现,因为每次测试运行都会在不同的地方失败.一种解决方案是在单独的显示中执行每个浏览器.例如.你可以使用 Xvfb:

@djangofan: Wrong. You cannot lock the focus. After you requested focus in one window and before you trigger an action, another window requests focus, and your action (like sending keys to input field) just doesn't work. This happened in our tests several times daily. It was hard to reproduce, because with each test run it failed on different places. A solution is to execute each browser in a separate display. E.g. you can use Xvfb:

  Xvfb ... -screen 1 1200x800x24 -screen 2 1200x800x24 ...

然后,当您启动浏览器时,为其分配一个单独的屏幕:

Then when you start a browser, assign a separate screen to it:

  browser.setEnvironmentProperty("DISPLAY", ":N.1");
  browser.setEnvironmentProperty("DISPLAY", ":N.2");
  ...

这篇关于Selenium Webdriver 测试期间的多个 Firefox 实例未正确处理焦点.的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆