• appium-java,连接真机启动微信(适应于安卓8.0及以上,新版appium)


    1.同理设置appium配置,要启动多少台机器就启动多少个appium,注意端口号不能重复

     2.

        public DesiredCapabilities getCapabilities(int i,String appName){
            //配置appuim信息
            DesiredCapabilities capabilities = new DesiredCapabilities();  
            switch (i) {
            case 1:
                capabilities.setCapability("platformName", "Android");  //手机操作系统
                capabilities.setCapability("deviceName", "device"); //手机类型
                capabilities.setCapability("udid", "712CKCRXXXX");  //连接手机的唯一标识
                capabilities.setCapability("platformVersion", "7.0");  //操作系统版本
                //H5驱动关键,不配置webview会被识别成com.tencent.mm的webview,不是com.tencent.mm:tools的(旧版本需配置新版不需要)
    //            ChromeOptions op= new ChromeOptions();
    //            op.setExperimentalOption("androidProcess", "com.tencent.mm:tools");
    //            capabilities.setCapability(ChromeOptions.CAPABILITY, op);
                break;
            case 2:
                capabilities.setCapability("platformName", "Android");  
                capabilities.setCapability("deviceName","device");
                capabilities.setCapability("udid", "HLRDU20309XXXX");
                capabilities.setCapability("platformVersion", "10");  
                break;
            default:
                break;
            }
            switch (appName) {
    		case "微信":
    			capabilities.setCapability("appPackage", "com.tencent.mm");  //app包名
    	        capabilities.setCapability("appActivity", ".ui.LauncherUI"); //要启动的Android Activity名
    			break;
    		default:
    			break;
    		}
            capabilities.setCapability("skipServerInstallation", true);//是否跳过appiumServer安装
    		capabilities.setCapability("skipDeviceInitialization", true);//是否跳过appiumDevice安装
            capabilities.setCapability("noReset", true); //不要在会话前重置应用状态
            capabilities.setCapability("fullReset", false); //Android是否删除应用,IOS是否删除整个模拟器目录
            capabilities.setCapability("unicodeKeyboard", true); //是否启动Unicode输入法
            capabilities.setCapability("resetKeyboard", true);  //结束后是否切换回默认输入法
            return capabilities;  
        }
    

      3.使用例子

        private AndroidDriver AndroidDriver;
        @Before
        public void setUp() throws Exception {
            
            try {
                AndroidDriver = new AndroidDriver(new URL("http://0.0.0.0:4723/wd/hub"), Start_Driver.get_capabilities(1));
            } catch (MalformedURLException e) {
                // TODO Auto-generated catch block
                e.printStackTrace();
            }  
        }
  • 相关阅读:
    PAT 乙级 1012 数字分类 (20) C++版
    PAT 乙级 1026 程序运行时间(15) C++版
    PAT 乙级 1009 说反话 (20) C++版
    PAT 乙级 1042 字符统计(20) C++版
    PAT 乙级 1046 划拳(15) C++版
    PAT 乙级 1063 计算谱半径(20) C++版
    CentOS安装oracle12C
    linux端口详解
    yum提示字符编码错误
    securecrt中文乱码
  • 原文地址:https://www.cnblogs.com/yanzhe/p/13143256.html
Copyright © 2020-2023  润新知