"how to address “the constructor chromedriver(capabilities) is deprecated” and webdriverexception: timed out error with chromedriver and chrome" Code Answer

4

it seems you were almost there. you need to use the method merge() from mutablecapabilities class to merge the desiredcapabilities type of object into chromeoptions type object and initiate the webdriver and webclient instance by passing the chromeoptions object as follows :

string exepath = "src\drivers\chromedriver.exe";
system.setproperty("webdriver.chrome.driver", exepath);
string downloadfilepath = "u:\data\download";
hashmap<string, object> chromeprefs = new hashmap<string, object>();
chromeprefs.put("profile.default_content_settings.popups", 0);
chromeprefs.put("download.default_directory", downloadfilepath);
chromeoptions options = new chromeoptions();
options.setexperimentaloption("prefs", chromeprefs);
desiredcapabilities cap = desiredcapabilities.chrome();
cap.setcapability(capabilitytype.accept_ssl_certs, true);
cap.setcapability(chromeoptions.capability, options);
options.merge(cap);
driver = new chromedriver(options);
By Marwan Alkhweldi on August 21 2022

Answers related to “how to address “the constructor chromedriver(capabilities) is deprecated” and webdriverexception: timed out error with chromedriver and chrome”

Only authorized users can answer the Search term. Please sign in first, or register a free account.