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)