Setting Chrome options

I have problem setting chrome options while running Android Web TestNG Java tests.

I have used the following ways,

  1. capabilities.setCapability(ChromeOptions.CAPABILITY, cOptions);
  2. capabilities.setCapability(“goog:chromeOptions”, cOptions);
  3. capabilities.setCapability(“chromeOptions”, cOptions);
  4. capabilities.setCapability(AndroidMobileCapabilityType.CHROME_OPTIONS, cOptions);

If I am not wrong, 3 and 4 should not work as the “chromeOptions” is updated to “goog:chromeOptions” in the Selenium latest versions

Appium version used: 1.7.1
Chrome version: 65

Code used:

if(config.getBrowser().equalsIgnoreCase("Chrome")) {
            Logger.log("Disabling save password");
            ChromeOptions cOptions = new ChromeOptions();
            Map<String, Object> prefs = new HashMap<>();
            prefs.put("credentials_enable_service", false);
            prefs.put("profile.password_manager_enabled", false);
            cOptions.setExperimentalOption("prefs", prefs);

            capabilities.setCapability(ChromeOptions.CAPABILITY, cOptions);
        }

Appium Log:

2019-09-09 09:12:19:674 - [Appium] Welcome to Appium v1.7.1
2019-09-09 09:12:19:708 - [Appium] Non-default server args:
2019-09-09 09:12:19:708 - [Appium]   logTimestamp: true
2019-09-09 09:12:19:709 - [Appium]   chromedriverExecutable: /opt/chromedriver/linux/65/chromedriver
2019-09-09 09:12:19:709 - [Appium]   platformName: Android
2019-09-09 09:12:19:709 - [Appium]   deviceName: 89RY0AE7H
2019-09-09 09:12:19:709 - [Appium]   browserName: Chrome
2019-09-09 09:12:19:709 - [Appium]   udid: 89RY0AE7H
2019-09-09 09:12:19:710 - [Appium] Deprecated server args:
2019-09-09 09:12:19:724 - [Appium]   --platform-name => --default-capabilities '{"platformName":"Android"}'
2019-09-09 09:12:19:725 - [Appium]   --device-name => --default-capabilities '{"deviceName":"89RY0AE7H"}'
2019-09-09 09:12:19:725 - [Appium]   --browser-name => --default-capabilities '{"browserName":"Chrome"}'
2019-09-09 09:12:19:725 - [Appium]   -U,--udid => --default-capabilities '{"udid":"89RY0AE7H"}'
2019-09-09 09:12:19:725 - [Appium] Default capabilities, which will be added to each request unless overridden by desired capabilities:
2019-09-09 09:12:19:732 - [Appium]   platformName: 'Android'
2019-09-09 09:12:19:745 - [Appium]   deviceName: '89RY0AE7H'
2019-09-09 09:12:19:745 - [Appium]   browserName: 'Chrome'
2019-09-09 09:12:19:746 - [Appium]   udid: '89RY0AE7H'
2019-09-09 09:12:19:911 - [Appium] Appium REST http interface listener started on 0.0.0.0:4723
2019-09-09 09:12:30:742 - [HTTP] --> POST /wd/hub/session {"desiredCapabilities":{"autoDismissAlerts":true,"browserName":"chrome","deviceName":"Android Emulator","goog:chromeOptions":{"args":[],"extensions":[],"prefs":{"credentials_enable_service":false,"profile.password_manager_enabled":false}},"nativeWebScreenshot":true,"newCommandTimeout":"60000","platformName":"android","resetKeyboard":true,"unicodeKeyboard":true},"capabilities":{"desiredCapabilities":{"autoDismissAlerts":true,"browserName":"chrome","deviceName":"Android Emulator","goog:chromeOptions":{"args":[],"extensions":[],"prefs":{"credentials_enable_service":false,"profile.password_manager_enabled":false}},"nativeWebScreenshot":true,"newCommandTimeout":"60000","platformName":"android","resetKeyboard":true,"unicodeKeyboard":true},"firstMatch":[{"browserName":"chrome","goog:chromeOptions":{"args":[],"extensions":[],"prefs":{"credentials_enable_service":false,"profile.password_manager_enabled":false}},"platformName":"android"}]}}
2019-09-09 09:12:30:781 - [debug] [MJSONWP] Calling AppiumDriver.createSession() with args: [{"autoDismissAlerts":true,"browserName":"chrome","deviceName":"Android Emulator","goog:chromeOptions":{"args":[],"extensions":[],"prefs":{"credentials_enable_service":false,"profile.password_manager_enabled":false}},"nativeWebScreenshot":true,"newCommandTimeout":"60000","platformName":"android","resetKeyboard":true,"unicodeKeyboard":true},null,{"desiredCapabilities":{"autoDismissAlerts":true,"browserName":"chrome","deviceName":"Android Emulator","goog:chromeOptions":{"args":[],"extensions":[],"prefs":{"credentials_enable_service":false,"profile.password_manager_enabled":false}},"nativeWebScreenshot":true,"newCommandTimeout":"60000","platformName":"android","resetKeyboard":true,"unicodeKeyboard":true},"firstMatch":[{"browserName":"chrome","goog:chromeOptions":{"args":[],"extensions":[],"prefs":{"credentials_enable_service":false,"profile.password_manager_enabled":false}},"platformName":"android"}]}]
2019-09-09 09:12:30:782 - [debug] [BaseDriver] Event 'newSessionRequested' logged at 1568020350782 (09:12:30 GMT+0000 (Coordinated Universal Time))
2019-09-09 09:12:30:784 - [Appium] Creating new AndroidDriver (v1.28.1) session
2019-09-09 09:12:30:784 - [Appium] Capabilities:
2019-09-09 09:12:30:785 - [Appium]   autoDismissAlerts: true
2019-09-09 09:12:30:785 - [Appium]   deviceName: 'Android Emulator'
2019-09-09 09:12:30:785 - [Appium]   goog:chromeOptions: { args: [],
  extensions: [],
  prefs:
   { credentials_enable_service: false,
     'profile.password_manager_enabled': false } }
2019-09-09 09:12:30:785 - [Appium]   nativeWebScreenshot: true
2019-09-09 09:12:30:786 - [Appium]   newCommandTimeout: '60000'
2019-09-09 09:12:30:786 - [Appium]   resetKeyboard: true
2019-09-09 09:12:30:786 - [Appium]   unicodeKeyboard: true
2019-09-09 09:12:30:786 - [Appium]   platformName: 'Android'
2019-09-09 09:12:30:787 - [Appium]   browserName: 'Chrome'
2019-09-09 09:12:30:787 - [Appium]   udid: '89RY0AE7H'
2019-09-09 09:12:30:832 - [BaseDriver] Capability 'newCommandTimeout' changed from string ('60000') to integer (60000). This may cause unexpected behavior
2019-09-09 09:12:30:845 - [BaseDriver] The following capabilities were provided, but are not recognized by appium: autoDismissAlerts, goog:chromeOptions.
2019-09-09 09:12:30:847 - [BaseDriver] Session created with session id: 1a331852-3259-401b-9d74-3c09de4f9d41
2019-09-09 09:12:30:848 - [debug] [AndroidDriver] Getting Java version
2019-09-09 09:12:31:201 - [AndroidDriver] Java version is: 1.8.0_151
2019-09-09 09:12:31:202 - [AndroidDriver] We're going to run a Chrome-based session
2019-09-09 09:12:31:202 - [AndroidDriver] Chrome-type package and activity are com.android.chrome and com.google.android.apps.chrome.Main
2019-09-09 09:12:31:207 - [ADB] Checking whether adb is present
2019-09-09 09:12:31:218 - [ADB] Using adb from /opt/dev/android-sdk-linux/platform-tools/adb
2019-09-09 09:12:31:218 - [AndroidDriver] Retrieving device list
2019-09-09 09:12:31:218 - [debug] [ADB] Trying to find a connected android device
2019-09-09 09:12:31:219 - [debug] [ADB] Getting connected devices...
2019-09-09 09:12:31:351 - [debug] [ADB] 1 device(s) connected
2019-09-09 09:12:31:352 - [AndroidDriver] Using device: 89RY0AE7H
2019-09-09 09:12:31:353 - [ADB] Checking whether adb is present
2019-09-09 09:12:31:367 - [ADB] Using adb from /opt/dev/android-sdk-linux/platform-tools/adb
2019-09-09 09:12:31:368 - [debug] [ADB] Setting device id to 89RY0AE7H
2019-09-09 09:12:31:368 - [AndroidDriver] App file was not listed, instead we're going to run com.android.chrome directly on the device
2019-09-09 09:12:31:369 - [debug] [AndroidDriver] Checking whether package is present on the device
2019-09-09 09:12:31:369 - [debug] [ADB] Getting connected devices...

How can I fix this issues. The pop up is making our tests flaky.