ChromeDriver (Feature Capabilities) Deprecated

I am using ChromeDriver 2.33c WebDriver 3.6.0and trying to set the default directory for file upload.

Map<String, Object> prefs = new HashMap<String, Object>();
prefs.put("download.default_directory", Vars.DOWNLOAD_FOLDER_ROOT);
DesiredCapabilities caps = DesiredCapabilities.chrome();

ChromeOptions options = new ChromeOptions();
options.addArguments("--start-maximized");
options.setExperimentalOption("prefs", prefs);
caps.setCapability(ChromeOptions.CAPABILITY, options);
driver = new ChromeDriver(caps);

I found this in the docs:

Use ChromeDriver (ChromeOptions) instead. Creates a new ChromeDriver example. Capabilities will be transferred to the chromedriver service.

+4
source share
2 answers

Hope you wanted to ask for a workaround to avoid obsolescence.

The old simple build method is Capabilitiesdeprecated. Now, ChromeDriverServiceand is required as parameters Capabilities. So, just build a ChromeDriverServiceand pass the same thing along with yours Capabilitiesto remove the failure warning.

DesiredCapabilities capabilities = DesiredCapabilities.chrome();

ChromeDriverService service = new ChromeDriverService.Builder()
                    .usingDriverExecutable(new File("/usr/local/chromedriver"))
                    .usingAnyFreePort()
                    .build();
ChromeDriver driver = new ChromeDriver(service, capabilities);

EDIT: ChromeDriver(service, capabilities) ,

DesiredCapabilities capabilities = DesiredCapabilities.chrome();

ChromeDriverService service = new ChromeDriverService.Builder()
                            .usingDriverExecutable(new File("/usr/local/chromedriver"))
                            .usingAnyFreePort()
                            .build();
ChromeOptions options = new ChromeOptions();
options.merge(capabilities);    
ChromeDriver driver = new ChromeDriver(service, options);

DesiredCapabilities ChromeOptions setCapability, ,

ChromeOptions options = new ChromeOptions();
options.setCapability("capability_name", "capability_value");
driver = new ChromeDriver(options);
+7

chrome :

ChromeOptions options = new ChromeOptions();
    // Proxy proxy = new Proxy();
    // proxy.setHttpProxy("myhttpproxy:3337");
    // options.setCapability("proxy", proxy);
    // options.addArguments("--headless");
    // options.addArguments("--disable-gpu");
    // options.setAcceptInsecureCerts(true);
    // options.addArguments("--allow-insecure-localhost");
    // options.addArguments("--lang=fr-CA");
    options.addArguments("--start-maximized");
driver = new ChromeDriver(options);

, : https://sites.google.com/a/chromium.org/chromedriver/capabilities

+2

Source: https://habr.com/ru/post/1687618/


All Articles