[0.228][SEVERE]: bind() returned an error, errno=98: Address already in use (98)
Nov 20, 2017 1:03:49 PM org.openqa.selenium.remote.ProtocolHandshake createSession
INFO: Detected dialect: OSS
when you try to run multiple services on same port number, you will get binding error . From your logs, it is evident that A service is already running on the specific port number on which you fired up selenium server . Change the port number.
--httpPort=9000
Download the latest version of chrome driver and set the property .
You can download from here https://sites.google.com/a/chromium.org/chromedriver/
Related
I'm running simple Selenium test, which uses selenium version 4.0.0 and chromedriver version 109. I'm running automation test on Salesforce application, which logs into the application and performs some operation. In the middle of the test execution, I get below error:
Jan 23, 2023 7:58:23 PM org.openqa.selenium.devtools.Connection handle
INFO: <- {"method":"Inspector.detached","params":{"reason":"target_closed"}}
Jan 23, 2023 7:58:23 PM org.openqa.selenium.devtools.Connection handle
INFO: Method Inspector.detached called with 0 callbacks available
After this connection to the browser is lost and when any further selenium webdriver statement(e.g. findElement) is executed, I gives exception:
org.openqa.selenium.NoSuchWindowException: no such window: target window already closed
from unknown error: web view not found
Can someone please help me with this ?
I tried different ways to fix the problem, Removed 'Thread.sleep' and updated browser capabilities as mentioned in this post, but it didn't work:
org.openqa.selenium.WebDriverException: disconnected: received Inspector.detached event error during test execution using Selenium and Chromedriver
Below is a snippet of code I'm using to initialize chrome webdriver:
System.out.println("Initializing Chrome");
ChromeOptions options = new ChromeOptions();
//options.setBinary("C:/Program Files (x86)/Google/Chrome/Application");
options.addArguments("start-maximized");
options.setExperimentalOption("excludeSwitches",new String[]{"enable-automation"});
options.addArguments("--disable-extensions");
options.addArguments("--disable-infobars");
options.addArguments("--allow-running-insecure-content");
WDriver = new ChromeDriver(options);
//WDriver = new ChromeDriver();
WDriver.manage().timeouts().implicitlyWait(60,TimeUnit.SECONDS);
System.out.println("Chrome Initialization Complete");
But it seems to be opening two instances of chrome, this is displayed on the console:
Initializing Chrome
Starting ChromeDriver 78.0.3904.70 (edb9c9f3de0247fd912a77b7f6cae7447f6d3ad5-refs/branch-
heads/3904#{#800}) on port 12262
Only local connections are allowed.
Please protect ports used by ChromeDriver and related test frameworks to prevent access by malicious
code.
Nov 04, 2019 3:29:38 PM org.openqa.selenium.remote.ProtocolHandshake createSession
INFO: Attempting bi-dialect session, assuming Postel's Law holds true on the remote end
log4j:WARN No appenders could be found for logger
(org.apache.http.client.protocol.RequestAddCookies).
log4j:WARN Please initialize the log4j system properly.
log4j:WARN See http://logging.apache.org/log4j/1.2/faq.html#noconfig for more info.
[1572910181.451][WARNING]: Timed out connecting to Chrome, retrying...
Nov 04, 2019 3:29:43 PM org.openqa.selenium.remote.ProtocolHandshake createSession
INFO: Falling back to original OSS JSON Wire Protocol.
[1572910186.002][WARNING]: Timed out connecting to Chrome, retrying...
Nov 04, 2019 3:29:48 PM org.openqa.selenium.remote.ProtocolHandshake createSession
INFO: Detected dialect: OSS
Chrome Initialization Complete
Chrome Version: 78.0.3904.87
Chromedriver Version: chromedriver_78.0.3904.70
Selenium Version: 3.141.59
While the issue is not a major roadblock it is a bit annoying that it opens a 2nd instance of chrome that will eat memory while it is on standby.
Cheers.
There are a couple of things you need to take care:
This error message...
Nov 04, 2019 3:29:38 PM org.openqa.selenium.remote.ProtocolHandshake createSession
INFO: Attempting bi-dialect session, assuming Postel's Law holds true on the remote end
...implies that the ChromeDriver was unable to initiate/spawn a new WebBrowser i.e. Chrome Browser session.
As per the discussion Attempting bi-dialect session, assuming Postel's Law holds true on the remote end thread 'webdriver dispatcher' panicked at 'index out of bounds: the len is 0 but the index is 0 this issue was observed with Selenium Client v3.0.0-beta3 which was released on 2016-09-01 14:57:03 -0700.
Simon in a comment mentioned that:
The root cause was a ClassCastException. We now catch that exception, log the thing that we were trying to parse and continue with other attempts to complete the handshake. The fix was available in Selenium Client v3.0.0-beta4.
The most appropriate solution would have been to:
Upgrade Selenium to current level of Version 3.141.59.
You can find a detailed discussion in org.openqa.selenium.remote.ProtocolHandshake createSession INFORMATION: Attempting bi-dialect session with Selenium Grid
The next error message...
Nov 04, 2019 3:29:43 PM org.openqa.selenium.remote.ProtocolHandshake createSession
INFO: Falling back to original OSS JSON Wire Protocol.
[1572910186.002][WARNING]: Timed out connecting to Chrome, retrying...
Nov 04, 2019 3:29:48 PM org.openqa.selenium.remote.ProtocolHandshake createSession
INFO: Detected dialect: OSS
...also implies that the ChromeDriver/Chrome Browser combo you are using is not the recent one as the current implementation of ChromeDriver follows W3C and initial logs are as follows:
Starting ChromeDriver 78.0.3904.70 (edb9c9f3de0247fd912a77b7f6cae7447f6d3ad5-refs/branch-heads/3904#{#800}) on port 9626
Only local connections are allowed.
Please protect ports used by ChromeDriver and related test frameworks to prevent access by malicious code.
Nov 05, 2019 3:41:53 PM org.openqa.selenium.remote.ProtocolHandshake createSession
INFO: Detected dialect: W3C
Solution
Ensure that:
JDK is upgraded to current levels JDK 8u222.
Selenium is upgraded to current levels Version 3.141.59.
ChromeDriver is updated to current ChromeDriver v78.0 level.
Chrome is updated to current Chrome Version 78.0 level. (as per ChromeDriver v78.0 release notes)
Clean your Project Workspace through your IDE and Rebuild your project with required dependencies only.
(WindowsOS only) Use CCleaner tool to wipe off all the OS chores before and after the execution of your Test Suite.
(LinuxOS only) Free Up and Release the Unused/Cached Memory in Ubuntu/Linux Mint before and after the execution of your Test Suite.
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 some relevant discussion in:
Issue 1504: Unable to Open latest chrome using latest Selenium.
Issue 1451: Chrome 54+ session not created exception: Runtime.executionContextCreated has invalid 'context'
Outro
As per this jar-download.com article the createSession() in ProtocolHandshake.java file of Selenium v3.0.1 contained the following:
public Result createSession(HttpClient client, Command command)
throws IOException {
// Avoid serialising the capabilities too many times. Things like profiles are expensive.
Capabilities desired = (Capabilities) command.getParameters().get("desiredCapabilities");
desired = desired == null ? new DesiredCapabilities() : desired;
Capabilities required = (Capabilities) command.getParameters().get("requiredCapabilities");
required = required == null ? new DesiredCapabilities() : required;
String des = new BeanToJsonConverter().convert(desired);
String req = new BeanToJsonConverter().convert(required);
// Assume the remote end obeys the robustness principle.
StringBuilder parameters = new StringBuilder("{");
amendW3CParameters(parameters, des, req);
parameters.append(",");
amendOssParamters(parameters, des, req);
parameters.append("}");
LOG.info("Attempting bi-dialect session, assuming Postel's Law holds true on the remote end");
Optional result = createSession(client, parameters);
// Assume a fragile OSS webdriver implementation
if (!result.isPresent()) {
parameters = new StringBuilder("{");
amendOssParamters(parameters, des, req);
parameters.append("}");
LOG.info("Falling back to original OSS JSON Wire Protocol.");
result = createSession(client, parameters);
}
// Assume a fragile w3c implementation
if (!result.isPresent()) {
parameters = new StringBuilder("{");
amendW3CParameters(parameters, des, req);
parameters.append("}");
LOG.info("Falling back to straight W3C remote end connection");
result = createSession(client, parameters);
}
if (result.isPresent()) {
Result toReturn = result.get();
LOG.info(String.format("Detected dialect: %s", toReturn.dialect));
return toReturn;
}
throw new SessionNotCreatedException(
String.format(
"Unable to create new remote session. " +
"desired capabilities = %s, required capabilities = %s",
desired,
required));
}
Does anyone have a solution for this problem?
The driver is instantiated and the browser is opened, but then I get the following error:
[01:53:15,339] INFO [CheckOut-0] - ####### Test 'MyTestCases.CheckOut' started
Starting ChromeDriver (v2.9.248304) on port 17682
May 26, 2017 1:53:16 AM org.openqa.selenium.remote.ProtocolHandshake createSession
INFO: Attempting bi-dialect session, assuming Postel's Law holds true on the remote end
[0.183][WARNING]: PAC support disabled because there is no system implementation
May 26, 2017 1:53:18 AM org.openqa.selenium.remote.ProtocolHandshake createSession
INFO: Detected dialect: OSS
[01:53:20,832] INFO [CheckOut-0] - ####### Test 'MyTestCases.CheckOut' finished after 5491 ms
[01:53:20,838] INFO [CheckOut-0] - Cleaning up ...
enter image description here
I found Solution for the Problem. I had Old Libraries and replaced it with Selenium Libraries from Here and it worked.
I updated my project to use Marionette/gecko and when I try to run it I get this message:
1477424937782 geckodriver INFO Listening on 127.0.0.1:11146
Oct 25, 2016 3:48:58 PM org.openqa.selenium.remote.ProtocolHandshake createSession
INFO: Attempting bi-dialect session, assuming Postel's Law holds true on the remote end
1477424938364 mozprofile::profile INFO Using profile path C:\Users\Janet\AppData\Local\Temp\rust_mozprofile.iMfi1TUVjDFi
1477424938367 geckodriver::marionette INFO Starting browser C:\Program Files\Mozilla Firefox\firefox.exe
1477424938372 geckodriver::marionette INFO Connecting to Marionette on localhost:50333
1477424939344 Marionette INFO Listening on port 50333
Oct 25, 2016 3:49:01 PM org.openqa.selenium.remote.ProtocolHandshake createSession
INFO: Detected dialect: W3C
JavaScript warning: https://normandy.cdn.mozilla.net/static/bundles/selfrepair-910943d53dbd84b4c75a.a958f9d28733.js, line 7: mutating the [[Prototype]] of an object will cause your code to run very slowly; instead create the object with the correct initial [[Prototype]] value using Object.create
Element users was not found
use below code. You need to set the system property so that your geckodriver can be located
System.setProperty("webdriver.gecko.driver", "C:\\Selenium\\geckodriver.exe");
driver = new MarionetteDriver();
Neither of the example code snippets from the official Google Selenium Wiki (http://code.google.com/p/selenium/wiki/ChromeDriver) work for me. With either starting the Selenium server standalone or using the ChromeDriverService it hangs at line "new RemoteWebDriver(...)". Here's the output on my console:
/tmp/chromedriver: error while loading shared libraries: libbz2.so.1.0: cannot open shared object file: No such file or directory
Jun 29, 2011 8:46:58 AM org.openqa.selenium.net.UrlChecker waitUntilAvailable
INFO: Waiting for [Ljava.net.URL;#16df84b
Jun 29, 2011 8:46:58 AM org.openqa.selenium.net.UrlChecker$1 call
INFO: Polling http://localhost:21461/status
Jun 29, 2011 8:46:58 AM org.openqa.selenium.net.UrlChecker$1 call
INFO: Polling http://localhost:21461/healthz
Jun 29, 2011 8:46:59 AM org.openqa.selenium.net.UrlChecker$1 call
INFO: Polling http://localhost:21461/status
...
It is polling for healthz and status forever?
I believe this thread refers to the same problem as the one you're encountering:
http://code.google.com/p/chromium/issues/detail?id=13425
I had a similar problem. My Fedora had libbz2.so.1 in directory /lib64/ whilst Chrome was looking for it in /usr/lib64/
Solution was to create a symbolic link:
sudo ln -s /lib64/libbz2.so.1 /usr/lib64/libbz2.so.1.0
zilupe's answer lead me to the right answer for 32-bit CentOS:
sudo ln -s /lib/libbz2.so.1 /usr/lib/libbz2.so.1.0
Presumably his is right if you have 64-bit CentOS