码迷,mamicode.com
首页 > 移动开发 > 详细

Appium对手机chrome浏览器操作

时间:2018-07-05 00:40:15      阅读:822      评论:0      收藏:0      [点我收藏+]

标签:ppa   127.0.0.1   ESS   activity   androi   图片   port   import   end   

appium操作chrome浏览器

1.安卓手机下载手机版chrome浏览器
技术分享图片
2.Andriod setting中选择“chrome”
技术分享图片
3.通过css定位得到百度输入框为:#index-kw
技术分享图片
4.编写代码
import io.appium.java_client.AppiumDriver;
import io.appium.java_client.TouchAction;

import org.junit.*;
import org.junit.Before;
import org.junit.Test;
import org.openqa.selenium.By;
import org.openqa.selenium.WebElement;
import org.openqa.selenium.remote.CapabilityType;
import org.openqa.selenium.remote.DesiredCapabilities;
import org.openqa.selenium.remote.RemoteWebDriver;
import org.openqa.selenium.WebDriver;
public class chrome {
private AppiumDriver driver;
private static WebElement element = null;
int port=22;
String url="";br/>@Before
public void setUp() throws Exception {
DesiredCapabilities capabilities = new DesiredCapabilities();
capabilities.setCapability("platformName", "Android");
capabilities.setCapability("deviceName","xx");xx->手机设备号
capabilities.setCapability("platformVersion", "4.4");
capabilities.setCapability("unicodeKeyboard", true);
capabilities.setCapability("resetKeyboard", true);
capabilities.setCapability("browserName", "Chrome");
capabilities.setCapability("appPackage", "com.android.browser");
capabilities.setCapability("appActivity", ".BrowserActivity");
capabilities.setCapability("unicodeKeyboard",true);
capabilities.setCapability("resetKeyboard",true);
driver = new AppiumDriver(new URL("
http://127.0.0.1:4723/wd/hub"), capabilities);

}

@After
public void tearDown() throws Exception {br/>driver.quit();
}
@Test
public void addContact() throws InterruptedException{
driver.get("
http://m.baidu.com");
driver.findElementByCssSelector("#index-kw").sendKeys("suzhou");
}
}

Appium对手机chrome浏览器操作

标签:ppa   127.0.0.1   ESS   activity   androi   图片   port   import   end   

原文地址:http://blog.51cto.com/11959730/2136265

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!