网页、手机APP、小程序添加自动化测试的支持

自动化测试离不开源代码级别对自动化测试的支持。

小程序

给button添加automaitonid属性,对于小程序,自定义属性要添加data-前缀:

   
    演示一
  

对应的appium+python的小程序自动化测试脚本可以通过如下方式找到这个按钮:

# 通过添加的自定义属性点击小程序界面上的按钮
self.driver.find_element_by_css_selector('[data-automationid="demo1"]').click()

web网页

给登录按钮添加自定义属性automationid:

            
登 陆

对应的selenium+java的自动化测试脚本如下:

driver.findElement(By.cssSelector("button[automationid=button_login]"));
#或者driver.findElement(By.cssSelector("[automationid=button_login]"));

手机端Flutter

程序源代码:

#给按钮添加key,这个key可以用来做自动化测试
 floatingActionButton: FloatingActionButton(
        // Provide a Key to this button. This allows finding this
        // specific button inside the test suite, and tapping it.
        key: Key('increment'),
        onPressed: _incrementCounter,
        tooltip: 'Increment',
        child: Icon(Icons.add),
      ),
    );

对应的自动化测试代码(flutter):

#自动化测试时可以通过下面的代码找到这个按钮
    final buttonFinder = find.byValueKey('increment');

android原生app

d

你可能感兴趣的:(网页、手机APP、小程序添加自动化测试的支持)