• Appium 安卓计算器demo


    package testProject;
    
    import org.openqa.selenium.*;
    import org.openqa.selenium.remote.DesiredCapabilities;
    
    import io.appium.java_client.AppiumDriver;
    import io.appium.java_client.android.AndroidDriver;
    
    import java.net.MalformedURLException;
    import java.net.URL;
    import org.testng.annotations.Test;
    
    //import org.testng.annotations.BeforeClass;
    
    //import org.testng.annotations.AfterClass;
    
    import io.appium.java_client.AppiumDriver;
    import io.appium.java_client.android.AndroidDriver;
    import java.net.URL;
    import org.openqa.selenium.remote.CapabilityType;
    import org.openqa.selenium.remote.DesiredCapabilities;
    @SuppressWarnings("unused")
    public class AppiumDemo{
    
        public static void main(String[] args) throws MalformedURLException, InterruptedException {
    
            DesiredCapabilities capabilities = new DesiredCapabilities();
            capabilities.setCapability("deviceName", "20dfa4c5");
            //capabilities.setCapability("deviceName", "Android Emulator");
            capabilities.setCapability("automationName", "Appium");
            capabilities.setCapability("platformName", "Android");
            //capabilities.setCapability("platformVersion", "6.0");
            capabilities.setCapability("platformVersion", "6.0.1");
            capabilities.setCapability("appPackage", "com.sec.android.app.popupcalculator");
            capabilities.setCapability("appActivity", "com.sec.android.app.popupcalculator.Calculator");
            //capabilities.setCapability("appPackage", "com.android.calculator2");
            //capabilities.setCapability("appActivity", ".Calculator");
    
            @SuppressWarnings("rawtypes")
            AndroidDriver driver = new AndroidDriver(new URL("http://127.0.0.1:4723/wd/hub"), capabilities);
    
            driver.findElement(By.name("1")).click();
            driver.findElement(By.name("5")).click();
            driver.findElement(By.name("9")).click();
            //driver.findElement(By.name("delete")).click();
            driver.findElement(By.id("bt_backspace")).click();
            driver.findElement(By.id("bt_add")).click();
            driver.findElement(By.name("6")).click();
            driver.findElement(By.name("=")).click();
            driver.findElement(By.id("history_button")).click();
            driver.findElement(By.name("=")).click();
            //driver.findElement(By.id("bt_00")).click();
            Thread.sleep(2000);
    
            String result = driver.findElement(By.id("com.sec.android.app.popupcalculator:id/txtCalc")).getText();
            System.out.println(result);
    
            driver.quit();
        }
    
    }
  • 相关阅读:
    在intelij IDEA中添加对jetBrick文件的识别
    Android ScrollView 和ListView 一起使用的问题汇总
    关于android 内存的笔记
    Android 内存
    Adb 获取手机信息
    ADB command
    org.apache.http 源代码下载
    用Fiddler查看 Android/iOS 网络请求
    java Enum 类型互转
    InstallShield 制作MSI
  • 原文地址:https://www.cnblogs.com/felixer/p/9019468.html
Copyright © 2020-2023  润新知