Setting both debuggerAddress and download path using selenium with chromedriver - java

The bounty expires in 4 days. Answers to this question are eligible for a +50 reputation bounty.
arjun is looking for an answer from a reputable source.
I have been trying to set both the debuggerAddress and download directory options using chromedriver webdrivermanager (5.3.2) and selenium 4.8.0. Able to setup debuggerAddress option alone and works fine but when default_directory is used it gives error. Not sure if there is an option to set and use both. Any help or suggestions
WebDriverManager.chromedriver().setup();
ChromeOptions options = new ChromeOptions();
String downloadFilepath = "/new";
HashMap<String, Object> prefs = new HashMap<String, Object>();
prefs.put("profile.default_content_settings.popups", 0);
prefs.put("download.default_directory", downloadFilepath);
options.setExperimentalOption("prefs", prefs);
options.setExperimentalOption("debuggerAddress", "127.0.0.1:9222");
WebDriver driver = new ChromeDriver(options);
Error :
Could not start a new session. Response code 400. Message: invalid argument: entry 0 of 'firstMatch' is invalid
from invalid argument: cannot parse capability: goog:chromeOptions
from invalid argument: unrecognized chrome option: prefs
Host info: host: 'abc-UO2kkSNTJ', ip: ''
Build info: version: '4.8.0', revision: '267030adea'
System info: os.name: 'Windows Server 2019', os.arch: 'amd64', os.version: '10.0', java.version: '17.0.6'
Driver info: org.openqa.selenium.chrome.ChromeDriver
Command: [null, newSession {capabilities=[Capabilities {browserName: chrome, goog:chromeOptions: {args: [], debuggerAddress: 127.0.0.1:9222, extensions: [], prefs: {download.default_directory:
ew, profile.default_content_settings.popups: 0}}}], desiredCapabilities=Capabilities {browserName: chrome, goog:chromeOptions: {args: [], debuggerAddress: 127.0.0.1:9222, extensions: [], prefs: {download.default_directory:
ew, profile.default_content_settings.popups: 0}}}}]

The issue you are facing is because the debuggerAddress option and the download.default_directory option are not compatible with each other. When you set the debuggerAddress option, it starts a Chrome process with a remote debugging port, which means that the ChromeDriver can't control the Chrome instance anymore.
On the other hand, the download.default_directory option is used to set the default download directory for ChromeDriver to use. When you set this option, ChromeDriver sets a Chrome preference to save the downloaded files to the specified directory. However, this preference is set in the Chrome profile that ChromeDriver manages, which is not the same profile used by the remote debugging instance.
One way to work around this issue is to start a separate instance of Chrome using the --remote-debugging-port option and set the download directory for that instance. Here is an example code snippet that shows how to do this:
WebDriverManager.chromedriver().setup();
ChromeOptions options = new ChromeOptions();
String downloadFilepath = "/new";
HashMap<String, Object> prefs = new HashMap<String, Object>();
prefs.put("profile.default_content_settings.popups", 0);
options.setExperimentalOption("prefs", prefs);
options.setExperimentalOption("debuggerAddress", "127.0.0.1:9222");
Process process = Runtime.getRuntime().exec("google-chrome-stable --remote-debugging-port=9222 --user-data-dir=/tmp/chrome-profile --no-first-run --no-default-browser-check --disable-popup-blocking");
ChromeDriver driver = new ChromeDriver(options);
driver.executeScript("window.open();");
driver.switchTo().window(driver.getWindowHandles().toArray()[1].toString());
driver.get("chrome://settings/content/downloads");
driver.executeScript("document.querySelector('settings-ui').shadowRoot.querySelector('#main').querySelector('settings-basic-page').shadowRoot.querySelector('#basicPage > settings-section.expanded > settings-privacy-page').shadowRoot.querySelector('settings-downloads-page').shadowRoot.querySelector('downloads-section').shadowRoot.querySelector('settings-toggle-button').click();");
driver.executeScript("document.querySelector('settings-ui').shadowRoot.querySelector('#main').querySelector('settings-basic-page').shadowRoot.querySelector('#basicPage > settings-section.expanded > settings-privacy-page').shadowRoot.querySelector('settings-downloads-page').shadowRoot.querySelector('#downloadPath').value='"+downloadFilepath+"';");
driver.executeScript("document.querySelector('settings-ui').shadowRoot.querySelector('#main').querySelector('settings-basic-page').shadowRoot.querySelector('#basicPage > settings-section.expanded > settings-privacy-page').shadowRoot.querySelector('settings-downloads-page').shadowRoot.querySelector('#downloadPath').dispatchEvent(new Event('input', {bubbles: true}));");
driver.switchTo().window(driver.getWindowHandles().toArray()[0].toString());
This code starts a separate Chrome instance with remote debugging enabled and sets the download directory for that instance using a series of JavaScript commands. It then switches back to the original Chrome instance and continues with the WebDriver automation. Note that this approach requires that you have Google Chrome installed on your system.
I hope this helps!

Related

selenium for Ghost Browser / Chromium based browser, execution problems

I'm currently trying to write a script for Ghost Browser (Chromium based browser).
ChromeOptions options = new ChromeOptions();
options.setBinary("C:\\Users\\Admin\\AppData\\Local\\GhostBrowser\\Application\\ghost.exe");
ChromeDriver driver = new ChromeDriver(options);
driver.get("https://www.google.com");
I set the binary path of ChromeDriver to the path of Ghost Browser.
When I execute it, it executes but instantly closes, and gives the following error.
I don't know how to handle it, or what arguments to set in order to make it work,
please help.
SLF4J: Failed to load class "org.slf4j.impl.StaticLoggerBinder".
SLF4J: Defaulting to no-operation (NOP) logger implementation
SLF4J: See http://www.slf4j.org/codes.html#StaticLoggerBinder for further details.
Starting ChromeDriver 2.46.628402 (536cd7adbad73a3783fdc2cab92ab2ba7ec361e1) on port 51746
Only local connections are allowed.
Please protect ports used by ChromeDriver and related test frameworks to prevent access by malicious code.
Exception in thread "main" org.openqa.selenium.SessionNotCreatedException: Could not start a new session. session not created: Chrome version must be between 71 and 75
(Driver info: chromedriver=2.46.628402 (536cd7adbad73a3783fdc2cab92ab2ba7ec361e1),platform=Windows NT 10.0.19043 x86_64) (WARNING: The server did not provide any stacktrace information)
Command duration or timeout: 1.09 seconds
Build info: version: '4.1.0', revision: '87802e897b'
System info: host: 'ADMIN-PC', ip: '10.6.0.129', os.name: 'Windows 10', os.arch: 'amd64', os.version: '10.0', java.version: '17.0.1'
Driver info: org.openqa.selenium.chrome.ChromeDriver
Command: [null, newSession {capabilities=[Capabilities {browserName: chrome, goog:chromeOptions: {args: [], binary: C:\Users\Admin\AppData\Loca..., extensions: []}}], desiredCapabilities=Capabilities {browserName: chrome, goog:chromeOptions: {args: [], binary: C:\Users\Admin\AppData\Loca..., extensions: []}}}]
at java.base/jdk.internal.reflect.NativeConstructorAccessorImpl.newInstance0(Native Method)
at java.base/jdk.internal.reflect.NativeConstructorAccessorImpl.newInstance(NativeConstructorAccessorImpl.java:77)
at java.base/jdk.internal.reflect.DelegatingConstructorAccessorImpl.newInstance(DelegatingConstructorAccessorImpl.java:45)
at java.base/java.lang.reflect.Constructor.newInstanceWithCaller(Constructor.java:499)
at java.base/java.lang.reflect.Constructor.newInstance(Constructor.java:480)
at org.openqa.selenium.remote.ErrorHandler.createThrowable(ErrorHandler.java:217)
at org.openqa.selenium.remote.ErrorHandler.throwIfResponseFailed(ErrorHandler.java:169)
at org.openqa.selenium.remote.JsonWireProtocolResponse.lambda$errorHandler$0(JsonWireProtocolResponse.java:54)
at org.openqa.selenium.remote.HandshakeResponse.lambda$getResponseFunction$0(HandshakeResponse.java:30)
at org.openqa.selenium.remote.ProtocolHandshake.lambda$createSession$1(ProtocolHandshake.java:133)
at java.base/java.util.stream.ReferencePipeline$3$1.accept(ReferencePipeline.java:197)
at java.base/java.util.Spliterators$ArraySpliterator.tryAdvance(Spliterators.java:1002)
at java.base/java.util.stream.ReferencePipeline.forEachWithCancel(ReferencePipeline.java:129)
at java.base/java.util.stream.AbstractPipeline.copyIntoWithCancel(AbstractPipeline.java:527)
at java.base/java.util.stream.AbstractPipeline.copyInto(AbstractPipeline.java:513)
at java.base/java.util.stream.AbstractPipeline.wrapAndCopyInto(AbstractPipeline.java:499)
at java.base/java.util.stream.FindOps$FindOp.evaluateSequential(FindOps.java:150)
at java.base/java.util.stream.AbstractPipeline.evaluate(AbstractPipeline.java:234)
at java.base/java.util.stream.ReferencePipeline.findFirst(ReferencePipeline.java:647)
at org.openqa.selenium.remote.ProtocolHandshake.createSession(ProtocolHandshake.java:135)
at org.openqa.selenium.remote.ProtocolHandshake.createSession(ProtocolHandshake.java:84)
at org.openqa.selenium.remote.ProtocolHandshake.createSession(ProtocolHandshake.java:62)
at org.openqa.selenium.remote.HttpCommandExecutor.execute(HttpCommandExecutor.java:156)
at org.openqa.selenium.remote.service.DriverCommandExecutor.invokeExecute(DriverCommandExecutor.java:164)
at org.openqa.selenium.remote.service.DriverCommandExecutor.execute(DriverCommandExecutor.java:139)
at org.openqa.selenium.remote.RemoteWebDriver.execute(RemoteWebDriver.java:559)
at org.openqa.selenium.remote.RemoteWebDriver.startSession(RemoteWebDriver.java:246)
at org.openqa.selenium.remote.RemoteWebDriver.<init>(RemoteWebDriver.java:168)
at org.openqa.selenium.chromium.ChromiumDriver.<init>(ChromiumDriver.java:108)
at org.openqa.selenium.chrome.ChromeDriver.<init>(ChromeDriver.java:104)
at org.openqa.selenium.chrome.ChromeDriver.<init>(ChromeDriver.java:91)
at org.openqa.selenium.chrome.ChromeDriver.<init>(ChromeDriver.java:80)
at extras.testclass.main(testclass.java:16)
This error message...
Starting ChromeDriver 2.46.628402 (536cd7adbad73a3783fdc2cab92ab2ba7ec361e1) on port 51746
...implies that the ChromeDriver was unable to initiate/spawn a new Browsing Context i.e. google-chrome session.
Your main issue is the incompatibility between the version of the binaries you are using as:
You are using chromedriver=2.46 which is quite old and ancient.
Solution
Ensure that:
ChromeDriver is updated to current ChromeDriver v98.0 level.
Update
You need to download the latest ChromeDriver e.g. ChromeDriver v98.0.4758.102 and store it in your system. Next you have to mention the absolute path of the chromedriver executable through System.setProperty() line as follows:
System.setProperty("webdriver.chrome.driver", "C:\\path\\to\\chromedriver.exe");
ChromeOptions options = new ChromeOptions();
options.setBinary("C:\\Users\\Admin\\AppData\\Local\\GhostBrowser\\Application\\ghost.exe");
ChromeDriver driver = new ChromeDriver(options);
driver.get("https://www.google.com");

org.openqa.selenium.WebDriverException: Timed out waiting for driver server to start with Selenium and Java

I have tried everything that has been told in Stackoverflow topics. I have java selenium tests run on remote slave through jenkins. The absurd thing is first test always run and browsers opens, all other tests give me "Timed out waiting for driver server to start".
public WebDriver startChrome() {
System.setProperty("java.net.preferIPv4Stack", "true");
System.setProperty("webdriver.chrome.driver", "C:\\chromedriver.exe");
ChromeOptions chromeOptions = new ChromeOptions();
Map<String, Object> prefs = new HashMap<String, Object>();
prefs.put("credentials_enable_service", false);
prefs.put("profile.password_manager_enabled", false);
chromeOptions.addArguments("--no-sandbox");
chromeOptions.addArguments("--disable-dev-shm-usage");
chromeOptions.addArguments("--aggressive-cache-discard");
chromeOptions.addArguments("--disable-cache");
chromeOptions.addArguments("--disable-application-cache");
chromeOptions.addArguments("--disable-offline-load-stale-cache");
chromeOptions.addArguments("--disk-cache-size=0");
chromeOptions.addArguments("--dns-prefetch-disable");
chromeOptions.addArguments("--no-proxy-server");
chromeOptions.addArguments("--log-level=3");
chromeOptions.addArguments("--silent");
chromeOptions.addArguments("--disable-browser-side-navigation");
chromeOptions.setPageLoadStrategy(PageLoadStrategy.NORMAL);
chromeOptions.addArguments("-disable-cache");
chromeOptions.addArguments("-disable-extensions");
chromeOptions.addArguments("--incognito");
chromeOptions.addArguments("start-maximized");
//chromeOptions.setExperimentalOption("useAutomationExtension", false);
ChromeDriverService chromeDriverService = ChromeDriverService.createDefaultService();
port = chromeDriverService.getUrl().getPort();
return new ChromeDriver(chromeDriverService, chromeOptions);
}
Error:
Caused by: org.openqa.selenium.WebDriverException: Timed out waiting for driver server to start.
Build info: version: '4.0.0-alpha-7', revision: 'de8579b6d5'
System info: host: 'ISTDTSTYNMD04V', ip: '10.52.253.54', os.name: 'Windows Server 2016', os.arch: 'amd64', os.version: '10.0', java.version: '1.8.0_271'
Driver info: driver.version: unknown
at org.openqa.selenium.remote.service.DriverService.waitUntilAvailable(DriverService.java:231)
at org.openqa.selenium.remote.service.DriverService.lambda$start$0(DriverService.java:193)
at java.util.concurrent.CompletableFuture$AsyncSupply.run(CompletableFuture.java:1604)
at java.util.concurrent.CompletableFuture$AsyncSupply.exec(CompletableFuture.java:1596)
at java.util.concurrent.ForkJoinTask.doExec(ForkJoinTask.java:289)
at java.util.concurrent.ForkJoinPool$WorkQueue.runTask(ForkJoinPool.java:1067)
at java.util.concurrent.ForkJoinPool.runWorker(ForkJoinPool.java:1703)
at java.util.concurrent.ForkJoinWorkerThread.run(ForkJoinWorkerThread.java:172)
Caused by: org.openqa.selenium.net.UrlChecker$TimeoutException: Timed out waiting for [http://localhost:35592/status] to be available after 20000 ms
at org.openqa.selenium.net.UrlChecker.waitUntilAvailable(UrlChecker.java:90)
at org.openqa.selenium.remote.service.DriverService.waitUntilAvailable(DriverService.java:227)
... 7 more
Caused by: java.util.concurrent.TimeoutException
at java.util.concurrent.FutureTask.get(FutureTask.java:205)
at org.openqa.selenium.net.UrlChecker.waitUntilAvailable(UrlChecker.java:88)
... 8 more
All the solutions I have tried so far:
Update Java 1_8_271
Update Selenium 4
Update ChromeDriver 87
Check localhost traffic with rawcap
Check localhost dns definiton in etc/hosts
Update Chrome 87
Set Proxy
Check port availability
Check driver path
Kill all chrome and driver tasks before create (Only solution that worked, but not good for parallel tests)
Check localhost url and port is accessible with chrome -> http 200
When I try to reach url and port through java urlconnection in code driver create function catch block), it gives me connection reset but in chrome it gives 200.
All help will be appreciated.
Best Regards
This error message...
Caused by: org.openqa.selenium.WebDriverException: Timed out waiting for driver server to start.
Build info: version: '4.0.0-alpha-7', revision: 'de8579b6d5'
System info: host: 'ISTDTSTYNMD04V', ip: '10.52.253.54', os.name: 'Windows Server 2016', os.arch: 'amd64', os.version: '10.0', java.version: '1.8.0_271'
Driver info: driver.version: unknown
...implies that the ChromeDriver was unable to initiate/spawn a new Browsing Context i.e. Chrome Browser session.
A bit of more information about your usecase would have helped us to analyze the error in a better way. However to start with you can use only one single arguments start-maximized and remove all the other arguments which would get you started. So your effective code block will be:
public WebDriver startChrome() {
System.setProperty("webdriver.chrome.driver", "C:\\chromedriver.exe");
ChromeOptions chromeOptions = new ChromeOptions();
chromeOptions.addArguments("start-maximized");
ChromeDriverService chromeDriverService = ChromeDriverService.createDefaultService();
return new ChromeDriver(chromeDriverService, chromeOptions);
}
Additional Consideration
Ensure that:
JDK is upgraded to current levels JDK 8u271.
Selenium is upgraded to current released Version 3.141.59.
ChromeDriver is updated to current ChromeDriver v87.0 level.
Chrome is updated to current Chrome Version 87.0 level. (as per ChromeDriver v87.0 release notes).
If your base Web Client version is too old, then uninstall it and install a recent GA and released version of Web Client.
Take a System Reboot.
Execute your #Test as non-root user.
Always invoke driver.quit() within tearDown(){} method to close & destroy the WebDriver and Web Client instances gracefully.
References
You can find a couple of relevant detailed discussions in:
Selenium Chromedriver server times out despite being available
Driver info: driver.version: unknown with ChromeDriver Chrome using Selenium and Python
org.openqa.selenium.WebDriverException: Timed out waiting for driver server to start while initiating Chrome browser through Selenium

ChromeDriver Unable to add Performance Logging in Selenium Java

I have looked at the web search results and answers on stackoverflow on this topic but I couldn't find anyone having same issue. Following is code to enable performance logging that I am using:
ChromeOptions options = new ChromeOptions();
// options.addArguments("--headless");
options.addArguments("--remote-debugging-port=9222");
options.addArguments("--no-sandbox");
options.addArguments("--disable-application-cache");
options.addArguments("--disable-notifications");
options.addArguments("--disable-dev-shm-usage");
options.addArguments("--disable-extensions");
options.addArguments("--test-type");
options.addArguments("start-maximized");
options.addArguments("disable-infobars");
//options.addArguments("user-data-dir=C:\\apps\\selenium\\chrome\\data");
options.setExperimentalOption("useAutomationExtension", false);
options.setExperimentalOption("excludeSwitches", Collections.singletonList("enable-automation"));
// add Network logging
LoggingPreferences logPrefs = new LoggingPreferences();
logPrefs.enable(LogType.PERFORMANCE, Level.ALL);
options.setCapability(CapabilityType.LOGGING_PREFS, logPrefs);
Map<String, Object> perfLogPrefs = new HashMap<String, Object>();
perfLogPrefs.put("enableNetwork", true);
perfLogPrefs.put("traceCategories", "devtools.network");
options.setExperimentalOption("perfLoggingPrefs", perfLogPrefs);
webDriver = new ChromeDriver(options);
webDriver.manage().deleteAllCookies();
webDriver.manage().window().maximize();
When executed, it gives following error:
Starting ChromeDriver 80.0.3987.16 (320f6526c1632ad4f205ebce69b99a062ed78647-refs/branch-heads/3987#{#185}) on port 27252
Only local connections are allowed.
Please protect ports used by ChromeDriver and related test frameworks to prevent access by malicious code.
org.openqa.selenium.InvalidArgumentException: invalid argument: entry 0 of 'firstMatch' is invalid
from invalid argument: perfLoggingPrefs specified, but performance logging was not enabled
Build info: version: '3.141.59', revision: 'e82be7d358', time: '2018-11-14T08:17:03
What am I missing in above? The code examples use ChromeDriver(Capabilities) but that is deprecated. Is there some other setting that I need to enable before adding performance logging?
Thanks
I was able to find the answer on at SeleniumHQ issues. Essentially, CapabilityType.LOGGING_PREFS is broken in this version of ChromeDriver. I changed the line
options.setCapability(CapabilityType.LOGGING_PREFS, logPrefs);
to
options.setCapability("goog:loggingPrefs", logPrefs);
the preference name was changed to goog:loggingPrefs to be W3C compliant. I was able to collect network logs after this change.

Selenium, Firefox and GeckoDriver

I have a question and a problem.
Question:
By using Selenium 3.4.0 what is the latest version of Firefox that doesn't require GeckoDriver to run tests. Because using Firefox 45 i can run tests without GeckoDriver, although i thought it is required.
Problem:
I'm trying to use Firefox latest version 53.0, Selenium 3.4.0 and GeckoDriver 0.16.0
I set Firefox to the PATH. I set the path properties for Gecko as follows in this class: enter image description here
, Stack trace:
1493481035911 geckodriver INFO Listening on 127.0.0.1:32281 1493481036538 geckodriver::marionette INFO Starting browser \\?\C:\Program Files (x86)\Mozilla Firefox\firefox.exe with args ["-marionette"] 1493481037661 addons.manager ERROR startup failed: [Exception... "Component returned failure code: 0x80070057 (NS_ERROR_ILLEGAL_VALUE) [nsIFile.create]" nsresult: "0x80070057 (NS_ERROR_ILLEGAL_VALUE)" location: "JS frame :: resource://gre/modules/FileUtils.jsm :: FileUtils_getDir :: line 70" data: no] Stack trace: FileUtils_getDir()#resource://gre/modules/FileUtils.jsm:70 < FileUtils_getFile()#resource://gre/modules/FileUtils.jsm:42 < validateBlocklist()#resource://greJav/amSocdruilpets /eArdrdoorn:M arnageers.ojusrmc:e6:7/1/ g<r es/tmaordtuulpe(s)/#ArdedsoonuMracnea:g/e/rg.rjes/mm,o dluilnees /1A6d5d7o:n MNaSn_aEgReRrO.Rj_sNmO:T_INIT8I3A4L I<Z EsDt:a rAtdudpo(n)M#arneasgoeurr cies: /n/ogtr ei/nmiotdiualleized
s/AddonManager.jsm:3129 < observe()#resource://gre/components/addonManager.js:65
[GFX1]: Potential driver version mismatch ignored due to missing DLLs 0.0.0.0 and 0.0.0.0
1493481041925 Marionette INFO Listening on port 54083
JavaScript error: resource://gre/modules/AddonManager.jsm, line 2570: NS_ERROR_NOT_INITIALIZED: AddonManager is not initialized
Exception in thread "main" org.openqa.selenium.SessionNotCreatedException: Unable to create new remote session. desired capabilities = Capabilities [{marionette=true, browserName=firefox, moz:firefoxOptions=org.openqa.selenium.firefox.FirefoxOptions#150c158, version=, platform=ANY, firefox_profile=org.openqa.selenium.firefox.FirefoxProfile#4524411f}], required capabilities = Capabilities [{}]
Build info: version: 'unknown', revision: '8c03df6', time: '2017-03-02 09:30:17 -0800'
System info: host: 'DESKTOP-HUOROU4', ip: '192.168.43.167', os.name: 'Windows 10', os.arch: 'amd64', os.version: '10.0', java.version: '1.8.0_121'
Driver info: driver.version: FirefoxDriver
at org.openqa.selenium.remote.ProtocolHandshake.createSession(ProtocolHandshake.java:91)
at org.openqa.selenium.remote.HttpCommandExecutor.execute(HttpCommandExecutor.java:141)
at org.openqa.selenium.remote.service.DriverCommandExecutor.execute(DriverCommandExecutor.java:82)
at org.openqa.selenium.remote.RemoteWebDriver.execute(RemoteWebDriver.java:604)
at org.openqa.selenium.remote.RemoteWebDriver.startSession(RemoteWebDriver.java:244)
at org.openqa.selenium.remote.RemoteWebDriver.<init>(RemoteWebDriver.java:131)
at org.openqa.selenium.firefox.FirefoxDriver.<init>(FirefoxDriver.java:293)
at org.openqa.selenium.firefox.FirefoxDriver.<init>(FirefoxDriver.java:272)
at org.openqa.selenium.firefox.FirefoxDriver.<init>(FirefoxDriver.java:267)
at org.openqa.selenium.firefox.FirefoxDriver.<init>(FirefoxDriver.java:130)
at Test.main(Test.java:11)
Let me try to address your question one by one:
By using Selenium 3.4.0 what is the latest version of Firefox that doesn't require GeckoDriver to run tests - With Selenium 3.4.0 you can use Mozilla Firefox 47.x without gecko driver. From Mozilla Firefox 47.x on-wards gecko driver is mandatory.
With Selenium 3.4.0, geckodriver v0.16.1 & Mozilla Firefox 53.0 this piece of code works fine:
System.setProperty("webdriver.gecko.driver", "C:\\Utility\\BrowserDrivers\\geckodriver.exe");
DesiredCapabilities dc = DesiredCapabilities.firefox();
dc.setCapability("marionette", true);
WebDriver driver = new FirefoxDriver(dc);
driver.get("http://google.com/");
Moreover, if you are using any extensions in your default Firefox profile either you need to disable/delete them or create a new Firefox profile for your automation work.
Let me know if this helps you.

Unable to create new Chrome remote session

I'm trying to launch a new Chrome browser using Selenium Grid but ending up with the below error
Unable to create new remote session. desired capabilities = Capabilities [{browserName=chrome, version=55.0.2, platform=WINDOWS}], required capabilities = Capabilities [{}]
Build info: version: '3.0.1', revision: '1969d75', time: '2016-10-18 09:49:13 -0700'
System info: host: 'PL9710388', ip: '10.61.249.5', os.name: 'Windows 7', os.arch: 'amd64', os.version: '6.1', java.version: '1.8.0_111'
Driver info: driver.version: RemoteWebDriver
Below is my code to launch the Remote browser
java -Dwebdriver.chrome.driver=C:\chromedriver.exe -jar selenium-server-standalone-3.0.1.jar -role hub
java -Dwebdriver.chrome.driver=C:\chromedriver.exe -jar selenium-server-standalone-3.0.1.jar -role node
cap = DesiredCapabilities.chrome();
cap.setVersion("55.0.2");
cap.setBrowserName("chrome");
cap.setPlatform(org.openqa.selenium.Platform.WINDOWS);
browser = new RemoteWebDriver(new URL("http://localhost:4444/wd/hub"),cap);
Could you please help me on what is wrong?
make sure your code is able to find the chromedriver in your system. You can set the path programatically, you can even download and keep your driver from the below link
System.setProperty("webdriver.chrome.driver","/path to/chromedriver.exe");
cap = DesiredCapabilities.chrome();
cap.setPlatform(org.openqa.selenium.Platform.WINDOWS);
browser = new RemoteWebDriver(new URL("http://localhost:4444/wd/hub"),cap);
The line java -Dwebdriver.chrome.driver=C:\chromedriver.exe -jar selenium-server-standalone-3.0.1.jar -role node causes a plain vanilla node to be spun off which is agnostic of PLATFORM flavors (i.e., the node is not classified to recognize platform as a trait and is supposed to work as a generic node).
Your test code however seems to be specifying the platform as below
cap = DesiredCapabilities.chrome();
cap.setVersion("55.0.2");
cap.setBrowserName("chrome");
cap.setPlatform(org.openqa.selenium.Platform.WINDOWS);
To fix your problem please change your test code to look like below
cap = DesiredCapabilities.chrome(); // this sets the browser name. u dont need to do it again.
browser = new RemoteWebDriver(new URL("http://localhost:4444/wd/hub"),cap);
Once you have this, you should be able to execute tests properly.
Please dont forget to add the location to where your chromedriver binary exists to your PATH variable before starting the node, so that you dont see issues related to selenium not being able to find the chromedriver's location.
For general overview on working with Grid, you can refer to my blog post
I encounter the same and i found that the platform, browser name & browser version details were not matching the grid configuration. Specifically it was because i was using platrom as windows where i would have used VISTA. Also make sure you are using the hub URL instead of the node URL.Hub URL would be http://hubIP:port/wd/hub.
Refer below screenshot to get the right details about the node:

Categories