• 《exe应用程序UI自动化》


        前言:有很多公司做一些客户端的应用,每次发版都要耗费人力去手动回归比较费时,那么我们就想着去怎么去驱动人为的操作变为机器的操作过程,当然想着进行UI自动

          那么我们就要考虑怎么去实现exe应用程序的自动化,此刻引来了几个问题值得我们去思考

                1:exe的应用基于什么框架实现的其原理是什么?

                2:怎么去自动启动壳

                3:怎么去远程调式端口对壳子嵌入的网页进行做一些控制操作

    一:应用程序的实现原理

    1:exe的应用程序eg: electron 都是基于CEF开源的chromenium框架,selenium cef/electron(打包桌面程序)/qtwebbengine(渲染页面)

    2:ChromeDriver和Selenium是用于自动测试基于Chromium的应用程序的工具,可以使用多种语言编写:Java,Python等

    3:ChromeDriver使用DevTools远程调试协议(通过--remote-debugging-port=XXXX传递给应用程序命令行标志进行配置)与基于Chromium的应用程序进行通信进行一些页面元素的控制

    二:实例如下:

    1:安装JDK,然后将安装的bin目录添加到PATH的环境变量中

    2:创建一个自动化文件目录,用于存放启动的应用

    3:下载符合版本的驱动 chromedriver (http://chromedriver.storage.googleapis.com/index.html)

    4:创建一个maven项目 引入依赖的jar 第三方库 

    5:创建一个DriverInstant.java  (启动应用程序,此类是一个封装好的)

    import org.openqa.selenium.WebDriver;
    import org.openqa.selenium.chrome.ChromeDriver;
    import org.openqa.selenium.chrome.ChromeOptions;

    public class DriverInstant {
    private static WebDriver sInstant;//单例

    public static WebDriver getInstant(){
    if (sInstant==null) {
    //设置webdriver.chrome.driver属性
    System.setProperty("webdriver.chrome.driver", "D:/auto/chromedriver.exe");

    //声明chromeoptions,主要给chrome设置参数
    ChromeOptions options = new ChromeOptions();
    // 添加用户配置文件路径
    options.setBinary("D:/Ctrip/CtripAgentPlus/CtripAgentPlus.exe");
    options.addArguments("remote-debugging-port=远程调试端口号");

    //新建一个WebDriver的对象,但是New的是chrome的驱动 实例化chrome对象
    sInstant = new ChromeDriver(options);
    //WebDriver driver=new ChromeDriver();
    sInstant.get("嵌入的页面链接");
    System.out.println(sInstant.toString());
    }

    return sInstant;
    }

    }

  • 相关阅读:
    C/C++中volatile关键字详解(转)
    Spring中 @Autowired标签与 @Resource标签 的区别(转)
    [转]各种互斥量的总结
    nginx限制ip访问(转)
    HDU 4833 Best Financing (DP)
    HDU 4832 Chess (DP)
    HDU 4831 Scenic Popularity
    POJ 2155 Matrix (二维线段树)
    POJ 2155 Matrix (二维树状数组)
    HDU 4819 Mosaic (二维线段树)
  • 原文地址:https://www.cnblogs.com/Fannfiy/p/12794211.html
Copyright © 2020-2023  润新知