coteafs-appium 使用教程

coteafs-appium 使用教程

coteafs-appium:iphone: Wrapper Appium Framework in Java which supports Automation of Mobile and Tablet apps.项目地址:https://gitcode.com/gh_mirrors/co/coteafs-appium

1. 项目介绍

coteafs-appium 是一个基于 Java 的 Appium 框架封装,专门用于自动化测试移动和 tablet 应用程序。该框架支持 Android 和 iOS 的真实设备和模拟器,能够在运行时启动和停止服务器,并且可以连接到已经运行的服务器。此外,它还强制使用 Page Object 模型风格的编码,允许并行和顺序执行测试,并且所有的功能、回放和延迟设置都是通过配置文件可配置的。

2. 项目快速启动

环境准备

Java 开发环境Android SDKAppium 服务器

克隆项目




git clone https://github.com/WasiqB/coteafs-appium.git


cd coteafs-appium

配置文件

src/test/resources 目录下创建一个 Yaml 配置文件,例如 appium-config.yml,内容如下:




servers:


  android_server:


    host: 127.0.0.1


    port: 4723


    external: true


    logs:


      level: DEBUG


      path: logs/appium-server.log


      timestamp: true


      local_timezone: true


      debug_spacing: true


android:


  suppress_adb_kill: true


  devices:


    android:


      os: ANDROID


      name: Google Pixel 3


      version: 8.1


      type: SIMULATOR


  others:


    clear_files: true


    no_reset: false


    full_reset: true


    clear_logs: true


  automation: UIAUTOMATOR2


  android:


    avd:


      name: Pixel_3_XL_API_27


      launch_timeout: 60000


      ready_timeout: 60000


    args:


      -gpu swiftshader_indirect


    app:


      install_timeout: 60000


      type: HYBRID


      path: apps/android/VodQA.apk


      session_timeout: 120000


    playback:


      screenshot:


        on_error: true


      recording:

运行测试

编写测试用例并运行:




import org.junit.Test;


import org.openqa.selenium.By;


import org.openqa.selenium.WebElement;


import org.openqa.selenium.remote.DesiredCapabilities;


import io.appium.java_client.AppiumDriver;


import java.net.URL;


 


public class SampleTest {


    @Test


    public void testApp() throws Exception {


        DesiredCapabilities caps = new DesiredCapabilities();


        caps.setCapability("platformName", "Android");


        caps.setCapability("deviceName", "Pixel_3_XL_API_27");


        caps.setCapability("app", "path/to/your/app.apk");


        AppiumDriver driver = new AppiumDriver(new URL("https://127.0.0.1:4723/wd/hub"), caps);


        WebElement element = driver.findElement(By.id("element_id"));


        element.click();


        driver.quit();


    }


}

3. 应用案例和最佳实践

应用案例

coteafs-appium 框架已被广泛应用于各种移动应用的自动化测试中,包括但不限于:

金融应用的 UI 测试电商应用的功能测试社交应用的性能测试

最佳实践

使用 Page Object 模型:通过 Page Object 模型来组织测试代码,提高代码的可维护性和可读性。配置文件管理:使用 Yaml 配置文件来管理测试环境、设备和应用的配置,便于管理和维护。并行测试执行:利用框架的并行测试执行功能,提高测试效率。

4. 典型生态项目

coteafs-appium 作为一个强大的自动化测试框架,与其他开源项目结合使用可以进一步提升测试效率和质量:

Jenkins:用于持续集成和持续部署,自动化测试流程。TestNG:用于组织和运行测试用例,支持并行测试执行

coteafs-appium:iphone: Wrapper Appium Framework in Java which supports Automation of Mobile and Tablet apps.项目地址:https://gitcode.com/gh_mirrors/co/coteafs-appium

© 版权声明

相关文章

暂无评论

您必须登录才能参与评论!
立即登录
暂无评论...