• 是的,目前大多采用appium+cucumber+testng实现测试框架,使用jenkins集成

    最终异常监控没有弄出来,但是整了一个try-catch时截屏

    如果大家有好招,还请多多分享哟

  • 目前没有再次遇到此问题,现使用的Appium版本v1.6.6-beta.3

  • 👍

  • 谢谢你的建议,我尝试一下

  • @terrychow LZ 这两天我拼命的整iOS并发测试,想向LZ请教一下😳

    通过iOS:idevice_id –l获取到Mac链接的设备UDID,但是如何自动获取哪一个设备的UDID呢?又如何知道该设备此时空闲呢?

  • 这个应该如何实施呢?

  • iOS - XCUITest

    第8个变更点没理清楚😆
    WebDriverAgent Connection to WDA timed out这个频繁出现的问题有没有关联?

    测试运行个4到5个小时之后,就会出现连接失败。目前我们就是通过过了几个小时之后,重新启动一下app来绕过的😅

  • 谢谢,明白了

    初始化时port使用的是builder.usingAnyFreePort();任意自由port应该没有关系,关键是udid这个参数并没有通过TestNG.xml传过来
    可能在某个环节还是出了点儿问题

  • 这种通过testng.xml文件传参,是不是就需要使用Selenium Grid

    我一直很混乱这两个方式,这两个是作为一个方式一起使用,还是可单独使用的呢?

  • TestNG.xml 文件配置

    <?xml version="1.0" encoding="UTF-8"?>
    <!DOCTYPE suite SYSTEM "http://testng.org/testng-1.0.dtd">
    <suite name="suite" parallel="classes" thread-count="3">
        <test verbose="2" name="Sales">
            <parameter name="port" value="4788"/>
            <parameter name="udid" value="9da82887884423f91840e4a4601862d2821de94a"/>
            <classes>
                <class name="rl.ipos.cucumberTest.CheckStoreCukesTest"/>
            </classes>
        </test>
        <test verbose="2" name="CustomerManage">
            <parameter name="port" value="4777"/>
            <parameter name="udid" value="2600ede04135ffc36df6c6e57cf2b4ad34c52f96"/>
            <classes>
                <class name="rl.ipos.cucumberTest.OpenShopCukesTest"/>
            </classes>
        </test>
    </suite> 
    

    iosDriver 初始化

    public class Driver {
        private int port;
        private String udid;
    
        protected static IOSDriver<IOSElement> iosDriver;
        protected static AppiumDriverLocalService service;
    
        @BeforeTest
        @Parameters({"port", "udid"})
        public void setPortUDID(int port, String udid) {
            this.port = port;
            this.udid = udid;
            System.out.println("\nport:" + port + ",udid:" + udid + "\n");
        }
    
        private int getPort() {
            return this.port;
        }
    
        private void setPort(int port) {
            this.port = port;
        }
    
        private void setUdid(String udid) {
            this.udid = udid;
        }
    
        private String getUdid() {
            return this.udid;
        }
    
        public static AppiumDriver getDriver() {
    
            Driver driver = null;
    
            if (iosDriver == null) {
    //            File file = new File(IPOSConfigPath.DRIVER_CONFIG_FILE);
    //            ObjectMapper objectMapper = new ObjectMapper();
    //
    //            try {
    //                driver = objectMapper.readValue(file, Driver.class);
    //
    //            } catch (IOException e) {
    //                System.out.println("配置文件错误");
    //            }
    
                AppiumServiceBuilder builder = new AppiumServiceBuilder();
                builder.usingAnyFreePort();
                builder.withIPAddress("127.0.0.1");
                service = AppiumDriverLocalService.buildService(builder);
    
                service.start();
    
                if (service == null || !service.isRunning()) {
                    throw new AppiumServerHasNotBeenStartedLocallyException("An appium server node is not started!");
                }
    
                File appDir = new File(System.getProperty("user.dir"), "/apps/");
                File app = new File(appDir, "rlterm3.app");
                DesiredCapabilities capabilities = new DesiredCapabilities();
                capabilities.setCapability(MobileCapabilityType.BROWSER_NAME, "");
                capabilities.setCapability(MobileCapabilityType.PLATFORM_VERSION, "10.3.0");
                capabilities.setCapability(MobileCapabilityType.DEVICE_NAME, "autotest");
                capabilities.setCapability(MobileCapabilityType.UDID, driver.getUdid());
                capabilities.setCapability(IOSMobileCapabilityType.LAUNCH_TIMEOUT, 500000);
                capabilities.setCapability(MobileCapabilityType.AUTOMATION_NAME, AutomationName.IOS_XCUI_TEST);
                capabilities.setCapability(MobileCapabilityType.APP, app.getAbsolutePath());
                capabilities.setCapability(MobileCapabilityType.NO_RESET, true);
                capabilities.setCapability("useNewWDA", true);
                iosDriver = new IOSDriver<>(service.getUrl(), capabilities);
                //每次Driver执行 找不到元素都会等待此处设置的时间
                iosDriver.manage().timeouts().implicitlyWait(480, TimeUnit.SECONDS);
                //如果在加载时间还不能加载完页面那会抛出超时异常
                // iosDriver.manage().timeouts().pageLoadTimeout(15, TimeUnit.SECONDS);
    
            }
            return iosDriver;
        }
    }
    

    Appium+cucumber

    测试启动时,通过cucumber找到对应步骤,每一步骤实例化driver

    protected AppiumDriver driver = Driver.getDriver();
    在这里实例化的时候报driver类这行代码空指针
    capabilities.setCapability(MobileCapabilityType.UDID, driver.getUdid());

    也就是说这个udid值并没有上传成功