• 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();
            }  
        }
  • 相关阅读:
    获取Enum枚举值描述的几法方法
    c# 快速验证代理IP是否有用
    解析JSON对象与字符串之间的相互转换
    MVC4相关Razor语法以及Form表单(转载)
    MVC4数据注解和验证
    C#在Json反序列化中处理键的特殊字符
    EasyUI 兼容 IE6 方法总结
    uploadify在IE6下的问题
    Could not resolve dependencies for project, Failed to read artifact descriptor for
    shell 文本单词计数
  • 原文地址:https://www.cnblogs.com/yanzhe/p/13143256.html
Copyright © 2020-2023  润新知