Appium Android 测试 Chrome 浏览器能正常启动 Chrome 浏览器,但是不能进行操作,求大神!!

zhuxuan · 2014年10月15日 · 最后由 恒温 回复于 2014年10月15日 · 2055 次阅读

chrome 能在 android 手机上启动 但是就是不能打开网站。或者操作 chrome 里面的按钮。求大神帮忙看下 ,万分感谢。
代码 :
private AppiumDriver ab =null;
@BeforeMethod
public void setUp(){
DesiredCapabilities capabilities = new DesiredCapabilities();
capabilities.setCapability(CapabilityType.BROWSER_NAME, "Chrome");
capabilities.setCapability("platformName","Android");
capabilities.setCapability("deviceName", "htcOne");
capabilities.setCapability("platformVersion", "4.4");
capabilities.setCapability("appPackage", "com.android.chrome");
capabilities.setCapability("appActivity", "com.google.android.apps.chrome.Main");
try {
ab = new AppiumDriver(new URL("http://127.0.0.1:4723/wd/hub"), capabilities);

} catch (MalformedURLException e) {
e.printStackTrace();
}
}
@AfterMethod
public void tearDown(){
ab.quit();
}
@Test
public void OpenWebsite(){
ab.findElementById("com.android.chrome:id/url_bar").sendKeys("www.baidu.com");
//ab.findElementByXPath("//android.widget.FrameLayout/android.widget.FrameLayout/android.widget.EditText[0]").sendKeys("www.baidu.com");
//ab.findElementByClassName("android.widget.ImageButton").click();
//ab.findElementByName("android.widget.EditText").sendKeys("www.baidu.com");
//ab.findElement(By.className("android.widget.EditText")).sendKeys("www.baidu.com");
//ab.get("www.baidu.com");

}
报错信息:
FAILED: OpenWebsite
org.openqa.selenium.NoSuchElementException: An element could not be located on the page using the given search parameters. (WARNING: The server did not provide any stacktrace information)
Command duration or timeout: 304 milliseconds
For documentation on this error, please visit: http://seleniumhq.org/exceptions/no_such_element.html
Build info: version: '2.42.1', revision: '68b415adb11acca4286be45124325cc36cfc4a51', time: '2014-05-29 09:21:55'
System info: host: 'wy', ip: '10.10.52.55', os.name: 'Windows 7', os.arch: 'amd64', os.version: '6.1', java.version: '1.7.0_51'
Session ID: 581b4fb9c6281f0b12c37308f3b1cc48
Driver info: io.appium.java_client.AppiumDriver
Capabilities [{platform=ANDROID, acceptSslCerts=true, javascriptEnabled=true, browserName=chrome, chrome={}, rotatable=false, locationContextEnabled=true, version=38.0.2125.102, takesHeapSnapshot=true, cssSelectorsEnabled=true, databaseEnabled=false, handlesAlerts=true, browserConnectionEnabled=false, nativeEvents=true, webStorageEnabled=true, applicationCacheEnabled=false, takesScreenshot=true}]
at sun.reflect.NativeConstructorAccessorImpl.newInstance0(Native Method)

共收到 1 条回复 时间 点赞

发帖的时候,不看发帖提示么?

需要 登录 后方可回复, 如果你还没有账号请点击这里 注册