Cannot run selenium java program after adding 3.0 jar file - java

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();

Related

Attempting bi-dialect session, assuming Postel's Law holds true on the remote end & Falling back to original OSS JSON using ChromeDriver and Selenium

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));
}

while doing selenium testing-- I am getting an error

[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/

Selenium GeckoDriver get IP and Port no of the launched driver instance

I'm using Selenium 3.4, Geckodriver 0.17.
I launch FirefoxDriver using the below code
System.setProperty("webdriver.gecko.driver", "geckodriver.exe");
FirefoxDriver driver = new FirefoxDriver();
driver.get("http://www.bing.com");
System.out.println(driver.getSessionId());
Is there a way I can get the IP and the port of the launched driver instance?
The data I want is printed in the logs.
1499170600204 geckodriver INFO Listening on 127.0.0.1:38840
1499170601127 geckodriver::marionette INFO Starting browser C:\Program Files\Mozilla Firefox\firefox.exe with args ["-marionette"]
[GFX1]: Potential driver version mismatch ignored due to missing DLLs igd10umd32 v= and igd10iumd32 v=
1499170608388 Marionette INFO Listening on port 12793
Jul 04, 2017 5:46:48 PM org.openqa.selenium.remote.ProtocolHandshake createSession
INFO: Detected dialect: W3C
The First line of the output 127.0.0.1:38840 prints the info I want. I don't want to parse the log as I will be running drivers in parallel.
The RemoteWebDriver has getCommandExecutor method.
Which can be TypeCasted to HttpCommandExecutor and getAddressOfRemoteServer() method returns the URL.
HttpCommandExecutor ce = (HttpCommandExecutor) driver.getCommandExecutor();
System.out.println(ce.getAddressOfRemoteServer());

Selenium ChromeDriver not Loading

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.

can't start neo4j service after moving directory

I have a windows 7 x64 machine. I installed neo4j which went very smoothly. I then managed to install neo4django and neo4j-embedded and that was fine too.
However I decided to change the directory it was in, so I stopped the neo4j service in powershell and moved it to a different spot. Since then I haven't been able to restart the service, though if I run the console it starts neo4j in a java.exe window (I think) and thus it works (localhost:7474 accessible, able to run the neo4j-embedded example script, etc) until I close that java.exe window.
Here is the output I got in PowerShell:
PS G:\dev files\neo4j\bin> .\neo4j start
[SC] StartService FAILED 1053:
The service did not respond to the start or control request in a timely fashion.
PS G:\dev files\neo4j\bin> .\neo4j console
25/06/13 9:36:57 PM org.neo4j.server.AbstractNeoServer INFO: Setting startup timeout to: 120000ms based on -1
Detected incorrectly shut down database, performing recovery..
25/06/13 9:36:59 PM org.neo4j.server.database.Database INFO: Loaded neo4j tuning properties from conf/neo4j.properties
25/06/13 9:37:01 PM org.neo4j.server.database.Database INFO: Successfully started database
25/06/13 9:37:02 PM org.neo4j.server.AbstractNeoServer INFO: Starting Neo Server on port [7474] with [80] threads available
25/06/13 9:37:02 PM org.neo4j.server.AbstractNeoServer INFO: Enabling HTTPS on port [7473]
25/06/13 9:37:03 PM org.neo4j.server.modules.DiscoveryModule INFO: Mounted discovery module at [/]
25/06/13 9:37:03 PM org.neo4j.server.modules.RESTApiModule INFO: Mounted REST API at [/db/data/]
25/06/13 9:37:03 PM org.neo4j.server.modules.ManagementApiModule INFO: Mounted management API at [/db/manage/]
25/06/13 9:37:03 PM org.neo4j.server.modules.WebAdminModule INFO: Mounted webadmin at [/webadmin]
21:37:03.260 [main] INFO org.mortbay.log - Logging to Logger[org.mortbay.log] via org.mortbay.log.Slf4jLog
25/06/13 9:37:03 PM org.neo4j.server.web.Jetty6WebServer INFO: Mounting static content at [/webadmin] from [webadmin-html]
21:37:03.366 [main] INFO org.mortbay.log - jetty-6.1.25
21:37:03.548 [main] INFO org.mortbay.log - NO JSP Support for /webadmin, did not find org.apache.jasper.servlet.JspServlet
21:37:06.088 [main] INFO org.mortbay.log - Started SelectChannelConnector#localhost:7474
I'd be most appreciative of your help. Cheers.
When you create a service in Windows you typically bind a location for the executable that the operating system can find. Because you moved the directory your Neo4J service is no longer valid. What you must do is delete the old service, recreate the service with the new directory, and then launch it.
Code to get and delete service in PowerShell:
$service = Get-WmiObject -Class Win32_Service -Filter "Name='servicename'"
$service.delete()
taken from here

Categories

Resources