<tfoot id='KisGR'></tfoot>

    <small id='KisGR'></small><noframes id='KisGR'>

    1. <i id='KisGR'><tr id='KisGR'><dt id='KisGR'><q id='KisGR'><span id='KisGR'><b id='KisGR'><form id='KisGR'><ins id='KisGR'></ins><ul id='KisGR'></ul><sub id='KisGR'></sub></form><legend id='KisGR'></legend><bdo id='KisGR'><pre id='KisGR'><center id='KisGR'></center></pre></bdo></b><th id='KisGR'></th></span></q></dt></tr></i><div id='KisGR'><tfoot id='KisGR'></tfoot><dl id='KisGR'><fieldset id='KisGR'></fieldset></dl></div>
      • <bdo id='KisGR'></bdo><ul id='KisGR'></ul>

    2. <legend id='KisGR'><style id='KisGR'><dir id='KisGR'><q id='KisGR'></q></dir></style></legend>

      “Chrome Legacy Window"的自动化(铬)使用 Winium

      Automation for quot;Chrome Legacy Windowquot; (Chromium) using Winium(“Chrome Legacy Window的自动化(铬)使用 Winium)

          <small id='gao1m'></small><noframes id='gao1m'>

            <i id='gao1m'><tr id='gao1m'><dt id='gao1m'><q id='gao1m'><span id='gao1m'><b id='gao1m'><form id='gao1m'><ins id='gao1m'></ins><ul id='gao1m'></ul><sub id='gao1m'></sub></form><legend id='gao1m'></legend><bdo id='gao1m'><pre id='gao1m'><center id='gao1m'></center></pre></bdo></b><th id='gao1m'></th></span></q></dt></tr></i><div id='gao1m'><tfoot id='gao1m'></tfoot><dl id='gao1m'><fieldset id='gao1m'></fieldset></dl></div>
          • <tfoot id='gao1m'></tfoot>

              <bdo id='gao1m'></bdo><ul id='gao1m'></ul>
              <legend id='gao1m'><style id='gao1m'><dir id='gao1m'><q id='gao1m'></q></dir></style></legend>
                <tbody id='gao1m'></tbody>
              • 本文介绍了“Chrome Legacy Window"的自动化(铬)使用 Winium的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着跟版网的小编来一起学习吧!

                问题描述

                我正在尝试使用 Winium 自动化 Windows 应用程序 GUI.该应用同时使用 WPF 窗口和Chrome Legacy Window"(Chromium) 窗口.

                我正在使用工具 "Automation Spy" 在 WPF 窗口中检查 GUI 元素的 ID 以与 Winium 一起使用.Automation Spy 无法检查Chrome Legacy Window"窗口中的元素,就像 Winium 无法访问这些元素一样.

                Chrome Legacy Window"是一个 WEB 窗口,因此需要使用 Selenium 进行自动化.

                我如何使用 Selenium 来挂钩 Chromium 窗口,它不是像 Firefox、Chrome 和类似浏览器的浏览器?

                解决方案

                远程调试端口"是我的问题的解决方案.

                1. 我将remote-debugging-port=XXXX"添加到我的 CEF(Chromium 嵌入式框架)命令中:https://blog.chromium.org/2011/05/remote-debugging-with-chrome-developer.html这让我可以通过 localhost:XXXX 查看和管理我的应用程序的 CEF 窗口.

                2. 我同时使用了 Winium 和 Selenium 来测试我的应用程序.Winium 用于我所有的 WPF 窗口,而 selenium 用于我的所有 CEF 窗口.我的 GUI 测试从 Winium 驱动程序开始,以打开我的应用程序并导航 WPF 窗口.每次我需要调试 CEF 窗口时,我都会使用 selenium 和remote-debugging-port"参数打开一个 Chrome 驱动程序,它允许我单击该窗口内的元素.当我完成这个 chromium 窗口时,我将关闭 selenium 驱动程序并继续使用 Winium.

                在 IntelliJ IDEA 中使用 Selenium 和 Winium

                Selenium 是一个可移植的框架,用于测试和自动化 Web 应用程序.Winium 是一个基于 Selenium 的工具,用于在 Windows 上测试和自动化桌面应用程序.要在 IntelliJ IDEA 项目中使用这些模块,请按照以下步骤操作:

                1. 下载 selenium-server-standalone jar 文件(例如 selenium-server-standalone-3.141.59.jar)https://www.seleniumhq.org/download/
                2. 下载 winium-webdriver jar 文件(例如 winium-webdriver-0.1.0-1.jar)http://central.maven.org/maven2/com/github/2gis/winium/winium-webdriver/0.1.0-1/
                3. 将两个 jars 添加到您的项目结构中:文件 → 项目结构 → 依赖项 → +
                4. 现在所有的 Selenium 和 Winium 导入都应该可以工作了.例如:

                  import org.openqa.selenium.By;导入 org.openqa.selenium.WebDriver;导入 org.openqa.selenium.chrome.ChromeDriver;导入 org.openqa.selenium.chrome.ChromeOptions;导入 org.openqa.selenium.support.ui.ExpectedConditions;导入 org.openqa.selenium.support.ui.WebDriverWait;导入 org.openqa.selenium.winium.DesktopOptions;导入 org.openqa.selenium.winium.WiniumDriver;导入 org.openqa.selenium.winium.WiniumDriverService;

                将 ChromeDriver 与 Selenium 一起使用

                按照以下步骤操作:

                1. 安装 Java JDK 并将其 bin 目录添加到系统 PATH变量.
                2. 创建一个包含所有文件的目录.本教程使用 c: emp.
                3. 下载 ChromeDriver 并解压(如 chromedriver_win32.zip 提供 chomedriver.exe)https://sites.google.com/a/chromium.org/chromedriver/下载
                4. 下载 selenium-server-standalone-X.X.X-alpha-1.zip(例如 selenium-server-standalone-4.0.0-alpha-1.zip)http://selenium-release.storage.googleapis.com/index.html
                5. 从 Cefbuilds 下载 CEF 二进制分发客户端并提取(例如 cef_binary_76.1.13+gf19c584+chromium-76.0.3809.132_windows64.tar.bz2)http://opensource.spotify.com/cefbuilds/index.html
                6. 您的目录结构现在应该如下所示:

                <块引用>

                c:	empcef_binary_3.2171.1979_windows32_client发布cefclient.exe(和其他文件)chromedriver.exeExample.javaselenium-server-standalone-2.44.0.jar

                有关更多信息,您可以阅读此 wiki:https://bitbucket.org/chromiumembedded/cef/wiki/UsingChromeDriver.md

                在 Winium 中使用 WiniumDriver

                按照以下步骤操作:

                1. 下载 Winium.Desktop.Driver.zip 并解压到 c: emphttps://github.com/2gis/Winium.Desktop/releases

                Java 代码示例

                启动一个winium驱动并打开你的应用:

                DesktopOptions desktopOption = new DesktopOptions();desktopOption.setApplicationPath("Path_to_your_app.exe");文件 drivePath = new File("C:\temp\Winium.Desktop.Driver.exe");WiniumDriverService 服务 = 新 WiniumDriverService.Builder().usingDriverExecutable(drivePath).usingPort(9999).withVerbose(true).withSilent(false).buildDesktopService();服务.start();WiniumDriver winiumDriver = WiniumDriver(service, desktopOption);

                使用 winium 导航和测试 WPF 窗口.例如:

                winiumDriver.findElement(By.id("someElementID")).click();

                创建一个 ChromeOptions 对象,该对象包含所有需要的 selenium 信息,例如 chromium 客户端和远程调试端口.确保将XXXX"端口更改为您的远程调试端口.

                System.setProperty("webdriver.chrome.driver", "c:/temp/chromedriver.exe");ChromeOptions chromeOptions = new ChromeOptions();chromeOptions.setBinary("c:/temp/cef_binary_76.1.13+gf19c584+chromium-76.0.3809.132_windows64_client/Release/cefclient.exe");chromeOptions.addArguments("远程调试端口=XXXX");

                使用 chrome 选项对象打开一个 chrome 驱动程序 (selenium).

                WebDriver seleniumDriver = ChromeDriver(chromeOptions);

                在铬窗口内使用元素.例如:

                seleniumWait.until(ExpectedConditions.visibilityOfElementLocated(By.className("someButtonClassName")));seleniumDriver.findElement(By.className("someButtonClassName")).click();

                完成 CEF 窗口后,关闭 selenium 驱动程序并继续使用 winium 驱动程序:

                seleniumDriver.quit();winiumDriver.findElement(By.id("someElementID")).click();

                关闭主winium驱动:

                winiumDriver.quit();

                I'm trying to automate a Windows application GUI using Winium. The app is using both WPF windows and "Chrome Legacy Window" (Chromium) windows.

                I'm using the tool "Automation Spy" to inspect the GUI elements' ids inside the WPF windows to use with Winium. Automation Spy can't inspect elements in the "Chrome Legacy Window" windows in the same manner that Winium can't access these elements.

                "Chrome Legacy Window" is a WEB window, so it requires automation with Selenium.

                How do I use Selenium to hook on a Chromium window, which is not a browser like Firefox, Chrome and similar?

                解决方案

                "Remote Debugging Port" was the solution for my problem.

                1. I added the "remote-debugging-port=XXXX" to my CEF (Chromium Embedded Framework) command: https://blog.chromium.org/2011/05/remote-debugging-with-chrome-developer.html This allowed me to see and manage my app's CEF windows through localhost:XXXX.

                2. I used both Winium and Selenium to test my app. Winium for all my WPF windows and selenium for all my CEF windows. My GUI test starts with Winium Driver to open my app and navigate WPF windows. Each time I need to debug a CEF window, I'm opening a Chrome Driver using selenium with the "remote-debugging-port" argument, which allows me to click elements inside that window. When I'm finish with this chromium window I'm closing the selenium driver and continues with Winium.

                Use Selenium and Winium with IntelliJ IDEA

                Selenium is a portable framework for testing and automating web applications. Winium is a Selenium-based tool for testing and automating desktop applications on Windows. In order to use these modules inside IntelliJ IDEA project, follow these steps:

                1. Download selenium-server-standalone jar file (e.g. selenium-server-standalone-3.141.59.jar) https://www.seleniumhq.org/download/
                2. Download winium-webdriver jar file (e.g. winium-webdriver-0.1.0-1.jar) http://central.maven.org/maven2/com/github/2gis/winium/winium-webdriver/0.1.0-1/
                3. Add both jars to your project structure: File → Project Structure → Dependencies → +
                4. Now all Selenium and Winium imports should work. For example:

                  import org.openqa.selenium.By;
                  import org.openqa.selenium.WebDriver;
                  import org.openqa.selenium.chrome.ChromeDriver;
                  import org.openqa.selenium.chrome.ChromeOptions;
                  import org.openqa.selenium.support.ui.ExpectedConditions;
                  import org.openqa.selenium.support.ui.WebDriverWait;
                  import org.openqa.selenium.winium.DesktopOptions;
                  import org.openqa.selenium.winium.WiniumDriver;
                  import org.openqa.selenium.winium.WiniumDriverService;
                  

                Use ChromeDriver with Selenium

                Follow these steps:

                1. Install the Java JDK and add its bin directory to your system PATH variable.
                2. Create a directory that will contain all files. This tutorial uses c: emp.
                3. Download ChromeDriver and extract it (e.g. chromedriver_win32.zip provides chomedriver.exe) https://sites.google.com/a/chromium.org/chromedriver/downloads
                4. Download selenium-server-standalone-X.X.X-alpha-1.zip (e.g. selenium-server-standalone-4.0.0-alpha-1.zip) http://selenium-release.storage.googleapis.com/index.html
                5. Download a CEF binary distribution client from Cefbuilds and extract (e.g. cef_binary_76.1.13+gf19c584+chromium-76.0.3809.132_windows64.tar.bz2) http://opensource.spotify.com/cefbuilds/index.html
                6. Your directory structure should now look similar to this:

                c:	emp
                  cef_binary_3.2171.1979_windows32_client
                    Release
                      cefclient.exe  (and other files)
                  chromedriver.exe
                  Example.java
                  selenium-server-standalone-2.44.0.jar
                

                For more information you can read this wiki: https://bitbucket.org/chromiumembedded/cef/wiki/UsingChromeDriver.md

                Use WiniumDriver with Winium

                Follow these steps:

                1. Download the Winium.Desktop.Driver.zip and extract it to c: emp https://github.com/2gis/Winium.Desktop/releases

                Java Code Example

                Start a winium driver and open your app:

                DesktopOptions desktopOption = new DesktopOptions();
                desktopOption.setApplicationPath("Path_to_your_app.exe");
                File drivePath = new File("C:\temp\Winium.Desktop.Driver.exe");
                WiniumDriverService service = new WiniumDriverService.Builder().usingDriverExecutable(drivePath).usingPort(9999).withVerbose(true).withSilent(false).buildDesktopService();
                service.start();
                WiniumDriver winiumDriver = WiniumDriver(service, desktopOption);
                

                Navigate and test WPF windows using winium. For example:

                winiumDriver.findElement(By.id("someElementID")).click();
                

                Create a ChromeOptions object which holds all needed selenium information such as chromium client and remote debugging port. Make sure to change the "XXXX" port to your remote debugging port.

                System.setProperty("webdriver.chrome.driver", "c:/temp/chromedriver.exe");
                ChromeOptions chromeOptions = new ChromeOptions();
                chromeOptions.setBinary("c:/temp/cef_binary_76.1.13+gf19c584+chromium-76.0.3809.132_windows64_client/Release/cefclient.exe");
                chromeOptions.addArguments("remote-debugging-port=XXXX");
                

                Open a chrome driver (selenium) using the chrome options object.

                WebDriver seleniumDriver = ChromeDriver(chromeOptions);
                

                Use element inside the chromium windows. For example:

                seleniumWait.until(ExpectedConditions.visibilityOfElementLocated(By.className("someButtonClassName")));
                seleniumDriver.findElement(By.className("someButtonClassName")).click();
                

                When you're done with the CEF window, close selenium driver and continue with the winium driver:

                seleniumDriver.quit();
                winiumDriver.findElement(By.id("someElementID")).click();
                

                Close main winium driver:

                winiumDriver.quit();
                

                这篇关于“Chrome Legacy Window"的自动化(铬)使用 Winium的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持跟版网!

                本站部分内容来源互联网,如果有图片或者内容侵犯了您的权益,请联系我们,我们会在确认后第一时间进行删除!

                相关文档推荐

                How can I detect integer overflow on 32 bits int?(如何检测 32 位 int 上的整数溢出?)
                Local variables before return statements, does it matter?(return 语句之前的局部变量,这有关系吗?)
                How to convert Integer to int?(如何将整数转换为整数?)
                How do I create an int array with randomly shuffled numbers in a given range(如何在给定范围内创建一个随机打乱数字的 int 数组)
                Inconsistent behavior on java#39;s ==(java的行为不一致==)
                Why is Java able to store 0xff000000 as an int?(为什么 Java 能够将 0xff000000 存储为 int?)

                1. <i id='QtS4u'><tr id='QtS4u'><dt id='QtS4u'><q id='QtS4u'><span id='QtS4u'><b id='QtS4u'><form id='QtS4u'><ins id='QtS4u'></ins><ul id='QtS4u'></ul><sub id='QtS4u'></sub></form><legend id='QtS4u'></legend><bdo id='QtS4u'><pre id='QtS4u'><center id='QtS4u'></center></pre></bdo></b><th id='QtS4u'></th></span></q></dt></tr></i><div id='QtS4u'><tfoot id='QtS4u'></tfoot><dl id='QtS4u'><fieldset id='QtS4u'></fieldset></dl></div>
                  <legend id='QtS4u'><style id='QtS4u'><dir id='QtS4u'><q id='QtS4u'></q></dir></style></legend>

                  <small id='QtS4u'></small><noframes id='QtS4u'>

                    <tbody id='QtS4u'></tbody>

                  • <bdo id='QtS4u'></bdo><ul id='QtS4u'></ul>

                        1. <tfoot id='QtS4u'></tfoot>