TA的每日心情 | 擦汗 3 小时前 |
---|
签到天数: 527 天 连续签到: 4 天 [LV.9]测试副司令
|
1测试积点
问题:
如何实现 Android 自带浏览器模拟百度搜索
本人今天刚接触Appium,遇到个问题想请大侠们指点迷津。
目的:用Android自带的浏览器模拟百度搜索。
问题:如何指定Android浏览器?
- <font face="微软雅黑" size="3">
- public class Test{
- private WebDriver driver;
- @Before
- public void setUp() throws Exception {
- // set up appium
- DesiredCapabilities capabilities = new DesiredCapabilities();
- capabilities.setCapability("device","selendroid");
- //------------------------------------下面的不知如何写--------------------------------------------------------------//
- //capabilities.setCapability("app", "/system/app/Browser.apk");
- //capabilities.setCapability("app", app.getAbsolutePath());
- //capabilities.setCapability("app-package", "com.android.browser");
- //capabilities.setCapability("app-activity", ".FMSActivity");
- //----------------------------------------------------------------------------------------------------------------------------//
- driver = new SwipeableWebDriver(new URL("http://127.0.0.1:4723/wd/hub"), capabilities);
- }
- @Test
- public void testcase_001() throws Exception{
- driver.get("http://www.baidu.com");
- WebDriverWait wait = new WebDriverWait(driver, 30);
- wait.until(ExpectedConditions.presenceOfElementLocated(By.name("wd")));
- WebElement keyword = driver.findElement(By.name("wd"));
- keyword.sendKeys("appium");
- driver.findElement(By.id("su1")).click();
- Thread.sleep(5000);
- }
- @After
- public void tearDown() throws Exception {
- driver.quit();
- }
- public class SwipeableWebDriver extends RemoteWebDriver implements HasTouchScreen {
- private RemoteTouchScreen touch;
- public SwipeableWebDriver(URL remoteAddress, Capabilities desiredCapabilities) {
- super(remoteAddress, desiredCapabilities);
- touch = new RemoteTouchScreen(getExecuteMethod());
- }
- public TouchScreen getTouch() {
- return touch;
- }
- }
- }</font>
复制代码
|
|