5

I have automated android chrome browser with the below code:

DesiredCapabilities capabilities=DesiredCapabilities.chrome();
ChromeOptions options=new ChromeOptions();  

options.setExperimentalOptions("androidPackage", "com.android.chrome");
capabilities.setCapability(ChromeOptions.CAPABILITY, options);

WebDriver driver=new ChromeDriver(capabilities);
System.setProperty("webdriver.chrome.driver", "C://Users//Documents//Appium//ChromeDriver//chromedriver.exe");
String url="http://yahoo.com";
driver.get(url);

I am trying to automate android chrome browser using C# (Visual Studio) but can't find the equivalent code. I am using this but not working:

Capabilities = DesiredCapabilities.Chrome();
ChromeOptions options1=new ChromeOptions();
options1.AddAdditionalCapability("androidPackage", "com.android.chrome",);
Driver = new ChromeDriver(Chrome_Driver, options1);
marc_s
  • 732,580
  • 175
  • 1,330
  • 1,459
Khushboo
  • 3,095
  • 2
  • 23
  • 24
  • I have raised the question here: https://groups.google.com/forum/#!topic/chromedriver-users/XTeGu710C2Q – Khushboo Mar 08 '14 at 09:19
  • Did you find an answer to this? The below answer posted by Pavel I find lacking because it uses RemoteWebDriver instead of ChromeDriver. Also, I do not want to instance the driver with a uri - I want to do that somewhere else in my code. – sapbucket Jul 14 '16 at 16:20

1 Answers1

1

I believe this is what you're looking for:

ChromeOptions chromeOptions = new ChromeOptions();
chromeOptions.AddAdditionalCapability("androidPackage", "com.android.chrome");

driver = new RemoteWebDriver(new Uri("http://seleniumhubaddress:4444/wd/hub"), chromeOptions.ToCapabilities());
Pavel
  • 31
  • 4
  • 2
    AddAdditionalCapability no longer supported by Selenium Chrome think it was depreciated in version 4 – Big Ian Oct 28 '22 at 11:53
  • Use ```chromeOptions.AddAdditionalOption("androidPackage", "com.android.chrome");``` instead. https://ultimateqa.com/selenium-4/ – Ashitakalax Jun 05 '23 at 15:43