无法在移动Chrome浏览器中导航

时间:2016-06-14 11:25:13

标签: java android appium selendroid java-client

我有以下代码,它将启动一个应用程序,并将切换到移动Chrome浏览器,并将导航到www.google.com

DesiredCapabilities capabilities = new DesiredCapabilities();
capabilities.setCapability("BROWSER_NAME","Android");
capabilities.setCapability("device","Android");
capabilities.setCapability("deviceName","hammerhead");
capabilities.setCapability("platformName","Android");
capabilities.setCapability("appPackage","com.android.calculator2");
capabilities.setCapability("appActivity","com.android.calculator2.Calculator"
              );
mobileDriver = new AndroidDriver(new URL(
                    "http://127.0.0.1:4723/wd/hub"), capabilities);
mobileDriver.startActivity("com.android.browser","com.android.browser.BrowserActivity");
mobileDriver.get("www.google.com");

当调用.get方法时,执行会抛出以下错误:

  

尚未实施。请帮助我们:http://appium.io

2 个答案:

答案 0 :(得分:0)

如果您的需求仅限于将Chrome浏览器打开到X url ,您应该查看ACTION_VIEW隐式Intent。

Intent browserIntent = new Intent(Intent.ACTION_VIEW, Uri.parse("http://www.google.com"));
startActivity(browserIntent);

答案 1 :(得分:0)

你可以简单地通过 -

来做到这一点
String urlString="http://127.0.0.1:4723/wd/hub";
Intent intent=new Intent(Intent.ACTION_VIEW,Uri.parse(urlString));
intent.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
intent.setPackage("com.android.chrome");
try {
    context.startActivity(intent);
} catch (ActivityNotFoundException ex) {
    // Chrome browser presumably not installed so allow user to choose instead
    intent.setPackage(null);
    context.startActivity(intent);
}