使用命令 aapt dump badging +apk名(查看apk包名及Activity)
package a;import java.net.MalformedURLException;import java.net.URL;import org.openqa.selenium.remote.DesiredCapabilities;import io.appium.java_client.AppiumDriver;import io.appium.java_client.android.AndroidDriver; public class Muke { public static void main(String[] args) throws InterruptedException, MalformedURLException { // TODO Auto-generated method stub AndroidDriver driver; DesiredCapabilities cap=new DesiredCapabilities(); cap.setCapability("deviceName","emulator-5554");//测试设备名称 cap.setCapability("platformVersion", "5.1.1");//平台版本 cap.setCapability("automationName", "Appium");//指定自动化的引擎,默认appium cap.setCapability("platformName", "Android");//平台名称 cap.setCapability("app", "E:\\BaiduNetdiskDownload\\com.tencent.androidqqmail_10129483.apk");//待测应用的绝对路径 cap.setCapability("appPackage", "com.tencent.androidqqmail");//应用的包名 cap.setCapability("appActivity", "com.tencent.qqmail.launcher.desktop.LauncherActivity");//应用启动的Activity名称 cap.setCapability("devicereadyTimeout", 30);//等等设备就绪的时间 cap.setCapability("unicodeKeyboard", true);//是否使用自定义的 cap.setCapability("resetKeyboard", true);//支持中文输入 driver = new AndroidDriver<>(new URL("http://127.0.0.1:4723/wd/hub"), cap); Thread.sleep(5000); driver.quit(); } }