1

I have the following code which will start an application and will switch to mobile chrome browser and will navigate to 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");

When .get method is called execution is throwing the below error:

Not yet implemented. Please help us: http://appium.io

manutd
  • 291
  • 1
  • 5
  • 18

2 Answers2

0

If your needs are limited to open the chrome browser to X url, you should look at the ACTION_VIEW implicit Intent.

Intent browserIntent = new Intent(Intent.ACTION_VIEW, Uri.parse("http://www.google.com"));
startActivity(browserIntent);
Alexandre Martin
  • 1,472
  • 5
  • 14
  • 27
  • After navigating if I need to input some data in search box also. In that case also I need to create Intent object? – manutd Jun 14 '16 at 11:50
  • which kind of data do you try to send in a search box ? If it is not sensitive informations, you could pass parameters by URL ? – Alexandre Martin Jun 14 '16 at 12:16
0

You can do it simply by -

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);
}
Neo
  • 3,546
  • 1
  • 24
  • 31