51Testing软件测试论坛
标题:
如何实现 Android 自带浏览器模拟百度搜索?
[打印本页]
作者:
测试积点老人
时间:
2018-11-27 11:01
标题:
如何实现 Android 自带浏览器模拟百度搜索?
本人今天刚接触Appium,遇到个问题想请大侠们指点迷津。
目的:用Android自带的浏览器模拟百度搜索。
问题:如何指定Android浏览器?
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;
}
}
}
复制代码
作者:
abcsell
时间:
2018-11-28 10:02
直接设置搜索网址
作者:
jingzizx
时间:
2018-11-28 11:04
有什么直接疑问或困难
作者:
qqq911
时间:
2018-11-28 11:22
用默认的
作者:
海海豚
时间:
2018-11-28 13:21
找到原生浏览器的包名,启动原生浏览器,然后百度搜索
欢迎光临 51Testing软件测试论坛 (http://bbs.51testing.com/)
Powered by Discuz! X3.2