最新消息: USBMI致力于为网友们分享Windows、安卓、IOS等主流手机系统相关的资讯以及评测、同时提供相关教程、应用、软件下载等服务。

android打开手机自带浏览器,【Appium】打开手机自带的浏览器

业界 admin 11浏览 0评论

简介:总结用appium打开Android自带的浏览器,本例使用手机的是小米6。

public class AppDemo {

private AppiumDriver driver;

@BeforeClass

public void setUp() throws Exception {

//设置自动化相关参数

DesiredCapabilities capabilities = new DesiredCapabilities();

//使用哪种移动平台

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

//启动哪种设备,是真机还是模拟器

capabilities.setCapability("deviceName","48cd544f");

//设置安卓系统版本

capabilities.setCapability("platformVersion", "7.1.1");

//不要再次安装apk

capabilities.setCapability("noReset",true);

//不用重新签名

capabilities.setCapability("noSign",true);

//设置包名

capabilities.setCapability("appPackage","com.android.browser");

//设置activity

capabilities.setCapability("appActivity","com.android.browser.BrowserActivity");

//初始化

driver = new AndroidDriver(new URL("http://127.0.0.1:4723/wd/hub"), capabilities);

}

@Test

public void openChrome() throws InterruptedException {

driver.get("http://www.baidu");

Thread.sleep(3000);

}

@AfterClass(enabled = false)

public void tearDown() throws Exception {

driver.quit();

}

简介:总结用appium打开Android自带的浏览器,本例使用手机的是小米6。

public class AppDemo {

private AppiumDriver driver;

@BeforeClass

public void setUp() throws Exception {

//设置自动化相关参数

DesiredCapabilities capabilities = new DesiredCapabilities();

//使用哪种移动平台

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

//启动哪种设备,是真机还是模拟器

capabilities.setCapability("deviceName","48cd544f");

//设置安卓系统版本

capabilities.setCapability("platformVersion", "7.1.1");

//不要再次安装apk

capabilities.setCapability("noReset",true);

//不用重新签名

capabilities.setCapability("noSign",true);

//设置包名

capabilities.setCapability("appPackage","com.android.browser");

//设置activity

capabilities.setCapability("appActivity","com.android.browser.BrowserActivity");

//初始化

driver = new AndroidDriver(new URL("http://127.0.0.1:4723/wd/hub"), capabilities);

}

@Test

public void openChrome() throws InterruptedException {

driver.get("http://www.baidu");

Thread.sleep(3000);

}

@AfterClass(enabled = false)

public void tearDown() throws Exception {

driver.quit();

}

发布评论

评论列表 (0)

  1. 暂无评论