打开 Selenium 浏览器的方法不与我当前的浏览器重叠 [英] Way to open Selenium browser not overlapping my current browser

查看:44
本文介绍了打开 Selenium 浏览器的方法不与我当前的浏览器重叠的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有以下情况.开始 Selenium 测试后,将打开一个浏览器窗口.因为我有一堆测试并且我每天都启动它们很多次,所以我不会让 Selenium 在我当前浏览器的前面(我工作的地方)打开新的浏览器窗口,而是在后台,所以它不会不要打扰我.可能吗?

I have following situation. once I start a Selenium test, a browser window will be opened. Since I have a bunch of tests and I start them many times every day, I would not let Selenium to open the new browser window on the front of my current browser(where I am working), but on the background, so it wouldn't disturb me. Is it possible?

PS 澄清为什么我需要这个 - 一天中很多次,当我在当前浏览器中工作并且 selenium 测试正在运行时,来自 Selenium 的浏览器窗口用于每个测试都是突然打开的,我可以突然关闭它,输入一些东西,等等.

PS to clarify why I need this - many times in a day, when I working in the current browser and the selenium tests are running, browser windows from Selenium for every test opens just suddenly and I can suddenly close it, type something, etc.

我现在拥有的:

推荐答案

开始软件测试自动化是一门艺术.您的测试平台应该是:

To start with Software Test Automation is an art. Your test bed should be:

  • 配置了所有必需的软件二进制文件.
  • 测试执行必须在受控环境中执行以优化性能.
  • 当您的 @Tests 正在执行时,它应该不受手动干预的影响.
  • 特别是当您的 @Tests 基于 Seleniumtest executionIn Progress测试环境不应该被干预,因为:

  • Configured with all the required softwares, libraries and binaries.
  • Test Execution must be performed in a controlled environment for optimized performance.
  • While your @Tests are executing, it should be free from Manual Intervention.
  • Particularly when your @Tests are Selenium based, while test execution is In Progress the Test Environment shouldn't be intervened because:

在最底层,actions class 的行为旨在尽可能地模仿远程端与实际输入设备的行为,实现策略可能涉及例如将合成事件注入浏览器事件循环.因此,调度 action 的步骤将不可避免地在特定于实现的领域结束.然而,某些内容可观察的效果必须在实现之间保持一致.为了适应这一点,规范要求远程端执行特定于实现的动作分派步骤,以及事件及其属性的列表.这份清单并不全面;特别是,输入源的默认操作可能会导致生成额外的事件,具体取决于浏览器的实现和状态(例如,当焦点位于可编辑元素上时,与关键操作相关的输入事件、滚动事件等).

At the lowest level, the behavior of actions class is intended to mimic the remote end's behavior with an actual input device as closely as possible, and the implementation strategy may involve e.g. injecting synthesized events into a browser event loop. Therefore the steps to dispatch an action will inevitably end up in implementation-specific territory. However there are certain content observable effects that must be consistent across implementations. To accommodate this, the specification requires that remote ends perform implementation-specific action dispatch steps, along with a list of events and their properties. This list is not comprehensive; in particular the default action of the input source may cause additional events to be generated depending on the implementation and the state of the browser (e.g. input events relating to key actions when the focus is on an editable element, scroll events, etc.).

此外,

WebDriver API 用户生成的激活触发器需要与真实用户与浏览器交互生成的激活触发器无法区分.特别是,分派的事件会将 isTrusted 属性设置为 true.调度这些事件的最健壮的方法是在浏览器实现本身中创建它们.将特定于操作系统的输入消息发送到浏览器的窗口有一个缺点,即正在自动化的浏览器可能无法与意外修改输入源状态的用户正确隔离.使用操作系统级别的可访问性 API 的缺点是浏览器的窗口必须聚焦,因此无法并行运行多个 WebDriver 实例.

An activation trigger generated by the WebDriver API user needs to be indistinguishable from those generated by a real user interacting with the browser. In particular, the dispatched events will have the isTrusted attribute set to true. The most robust way to dispatch these events is by creating them in the browser implementation itself. Sending OS-specific input messages to the browser's window has the disadvantage that the browser being automated may not be properly isolated from a user accidentally modifying input source state. Use of an OS-level accessibility API has the disadvantage that the browser's window must be focused, and as a result, multiple WebDriver instances cannot run in parallel.

  • 操作系统级可访问性 API 的一个优点是它保证输入正确反映用户输入,并在必要时允许与主机操作系统交互.但是,从机器利用率的角度来看,这可能会降低性能.

    An advantage of an OS-level accessibility API is that it guarantees that inputs correctly mirror user input, and allows interaction with the host OS if necessary. This might, however, have performance penalties from a machine utilisation perspective.

  • 此外,

    机器人类 用于生成本地系统输入事件,以用于测试自动化、自运行演示和其他需要控制鼠标和键盘的应用程序.Robot 的主要目的是促进 Java 平台实现的自动化测试.使用该类生成输入事件与将事件发布到 AWT 事件队列或 AWT 组件的不同之处在于,事件是在平台的本机输入队列中生成的.例如,Robot.mouseMove 会实际移动鼠标光标,而不仅仅是生成鼠标移动事件.

    Robot Class is used to generate native system input events for the purposes of test automation, self-running demos, and other applications where control of the mouse and keyboard is needed. The primary purpose of Robot is to facilitate automated testing of Java platform implementations. Using the class to generate input events differs from posting events to the AWT event queue or AWT components in that the events are generated in the platform's native input queue. For example, Robot.mouseMove will actually move the mouse cursor instead of just generating mouse move events.

    最后,根据 Internet Explorer和本地事件:

    由于 InternetExplorerDriver 仅适用于 Windows,因此它尝试使用所谓的本机"或操作系统级事件在浏览器中执行鼠标和键盘操作.这与对相同操作使用模拟 JavaScript 事件形成对比.使用原生事件的优势在于它不依赖于 JavaScript 沙箱,并且可以确保在浏览器中正确传播 JavaScript 事件.但是,当 IE 浏览器窗口没有焦点以及尝试将鼠标悬停在元素上时,鼠标事件目前存在一些问题.

    As the InternetExplorerDriver is Windows-only, it attempts to use so-called "native", or OS-level events to perform mouse and keyboard operations in the browser. This is in contrast to using simulated JavaScript events for the same operations. The advantage of using native events is that it does not rely on the JavaScript sandbox, and it ensures proper JavaScript event propagation within the browser. However, there are currently some issues with mouse events when the IE browser window does not have focus, and when attempting to hover over elements.

    浏览器焦点:

    挑战在于,如果窗口没有焦点,IE 本身似乎并不完全尊重我们发送给 IE 浏览器窗口(WM_MOUSEDOWN 和 WM_MOUSEUP)的 Windows 消息.具体来说,被点击的元素会在它周围收到一个焦点窗口,但元素不会处理点击.可以说,我们根本不应该发送消息;相反,我们应该使用 SendInput() API,但该 API 明确要求窗口具有焦点.我们与 WebDriver 项目有两个相互冲突的目标.

    The challenge is that IE itself appears to not fully respect the Windows messages we send the IE browser window (WM_MOUSEDOWN and WM_MOUSEUP) if the window doesn't have the focus. Specifically, the element being clicked on will receive a focus window around it, but the click will not be processed by the element. Arguably, we shouldn't be sending messages at all; rather, we should be using the SendInput() API, but that API explicitly requires the window to have the focus. We have two conflicting goals with the WebDriver project.

  • 首先,我们努力尽可能地模拟用户.这意味着使用原生事件而不是使用 JavaScript 模拟事件.

    First, we strive to emulate the user as closely as possible. This means using native events rather than simulating the events using JavaScript.

  • 其次,我们不希望浏览器窗口的焦点自动化.这意味着仅仅将浏览器窗口强制到前台是次优的.

    Second, we want to not require focus of the browser window being automated. This means that just forcing the browser window to the foreground is sub-optimal.

  • 始终将测试环境开发环境分开,并且完全不受人工干预的影响.

    Always keep the Test Environment seperate from Development Environment and absolutely free from Manual Intervention.

    这篇关于打开 Selenium 浏览器的方法不与我当前的浏览器重叠的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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