Unable to launch chrome from selenium, while using MAC system - java

MAC: 10.11.6,
Selenium: 2.53(Also tried with 3.4 and 3.8) &
Java 1.8
Driver settings tried:
String exePath ="/usr/local/Cellar/chromedriver/2.35/bin/chromedriver";
System.setProperty("webdriver.chrome.driver", exePath);
WebDriver driver = new ChromeDriver();
driver = new ChromeDriver(options);
Error stack trace:
Starting ChromeDriver 2.35.528157 (4429ca2590d6988c0745c24c8858745aaaec01ef) on port 14988
Only local connections are allowed.
Exception in thread "main" org.openqa.selenium.SessionNotCreatedException: session not created exception
from disconnected: unable to connect to renderer
(Session info: chrome=64.0.3282.140)
(Driver info: chromedriver=2.35.528157 (4429ca2590d6988c0745c24c8858745aaaec01ef),platform=Mac OS X 10.11.6 x86_64) (WARNING: The server did not provide any stacktrace information)
Command duration or timeout: 2.55 seconds
Build info: version: '2.53.1', revision: 'a36b8b1', time: '2016-06-30 17:32:46'
System info: host: '01hw382197', ip: '172.25.155.171', os.name: 'Mac OS X', os.arch: 'x86_64', os.version: '10.11.6', java.version: '1.8.0_111'
Driver info: org.openqa.selenium.chrome.ChromeDriver
at sun.reflect.NativeConstructorAccessorImpl.newInstance0(Native Method)
at sun.reflect.NativeConstructorAccessorImpl.newInstance(NativeConstructorAccessorImpl.java:62)
at sun.reflect.DelegatingConstructorAccessorImpl.newInstance(DelegatingConstructorAccessorImpl.java:45)
at java.lang.reflect.Constructor.newInstance(Constructor.java:423)
at org.openqa.selenium.remote.ErrorHandler.createThrowable(ErrorHandler.java:206)
at org.openqa.selenium.remote.ErrorHandler.throwIfResponseFailed(ErrorHandler.java:158)
at org.openqa.selenium.remote.RemoteWebDriver.execute(RemoteWebDriver.java:678)
at org.openqa.selenium.remote.RemoteWebDriver.startSession(RemoteWebDriver.java:249)
at org.openqa.selenium.remote.RemoteWebDriver.<init>(RemoteWebDriver.java:131)
at org.openqa.selenium.remote.RemoteWebDriver.<init>(RemoteWebDriver.java:144)
at org.openqa.selenium.chrome.ChromeDriver.<init>(ChromeDriver.java:170)
at org.openqa.selenium.chrome.ChromeDriver.<init>(ChromeDriver.java:159)
at org.openqa.selenium.chrome.ChromeDriver.<init>(ChromeDriver.java:116)
at dataAndConfig.DriverClass.getDriver(DriverClass.java:39)
at scriptsPostPaidWebApp.BillingPayNow.main(BillingPayNow.java:27)

Have a look at the following links:
https://github.com/SeleniumHQ/selenium/issues/4897
WebDriverError: disconnected: unable to connect to renderer
https://github.com/SeleniumHQ/selenium/issues/4979
First off you should make sure that your ChromeDriver supports your Chrome version. Since you are using ChromeDriver 2.3.5 and Google Chrome v64 you should be fine. (you still might want to upgrade your Selenium version)
According to the links posted above, you need to comment out every method that manipulates the window size of your browser in any way. e.g. setMaximize().
If that didnt work, you might want to give options.addArguments("no-sandbox"); a try.

Related

How can I fix this error when chrome starts

After starting a chrome driver in java a SessionNotCreatedException is thrown by the application.
This is the code:
System.setProperty("webdriver.chrome.driver", "D:\\Development\\Driver\\chromedriver.exe");
WebDriver webDriver = new ChromeDriver();
webDriver.get("https://google.com");
The exception:
Exception in thread "main" org.openqa.selenium.SessionNotCreatedException: Could not start a new session. Possible causes are invalid address of the remote server or browser start-up failure.
Build info: version: '4.0.0-beta-1', revision: '9c03156c2b'
System info: host: 'DESKTOP-S9O6TAK', ip: '192.168.0.211', os.name: 'Windows 10', os.arch: 'amd64', os.version: '10.0', java.version: '1.8.0_261'
Driver info: org.openqa.selenium.chrome.ChromeDriver
Command: [null, newSession {desiredCapabilities=Capabilities {browserName: chrome}}]
Capabilities {}
at org.openqa.selenium.remote.RemoteWebDriver.execute(RemoteWebDriver.java:635)
at org.openqa.selenium.remote.RemoteWebDriver.startSession(RemoteWebDriver.java:252)
at org.openqa.selenium.remote.RemoteWebDriver.(RemoteWebDriver.java:174)
at org.openqa.selenium.chromium.ChromiumDriver.(ChromiumDriver.java:82)
at org.openqa.selenium.chrome.ChromeDriver.(ChromeDriver.java:99)
at org.openqa.selenium.chrome.ChromeDriver.(ChromeDriver.java:86)
at org.openqa.selenium.chrome.ChromeDriver.(ChromeDriver.java:41)
at de.antonbowe.fachecker.FAChecker.(FAChecker.java:57)
at de.antonbowe.fachecker.FAChecker.main(FAChecker.java:63)
Caused by: java.lang.NullPointerException
at org.openqa.selenium.remote.ProtocolHandshake.createSession(ProtocolHandshake.java:122)
at org.openqa.selenium.remote.ProtocolHandshake.createSession(ProtocolHandshake.java:73)
at org.openqa.selenium.remote.HttpCommandExecutor.execute(HttpCommandExecutor.java:153)
at org.openqa.selenium.remote.service.DriverCommandExecutor.invokeExecute(DriverCommandExecutor.java:153)
at org.openqa.selenium.remote.service.DriverCommandExecutor.execute(DriverCommandExecutor.java:128)
at org.openqa.selenium.remote.RemoteWebDriver.execute(RemoteWebDriver.java:620)
... 8 more
Process finished with exit code 1
I updated the chrome driver several times and tried other old projects. All dont work.
When I was using selenium-java version 4.0.0-beta-3 alone, it worked fine. But after I added the following additional dependencies to my project (per https://developers.google.com/gmail/api/quickstart/java), I got the same errors.
google-api-client 1.23.0
google-oauth-client-jetty 1.23.0
google-api-services-gmail v1-rev83-1.23.0
I downgraded my selenium-java to version 3.141.59. The error went away.

I want to know the versions that I need to use to run a java selenium code

When I ran a simple java selenium code to start faceboook application, I am getting error "Timed out waiting for driver server to start."
Exception in thread "main" org.openqa.selenium.WebDriverException: Timed out waiting for driver server to start.
Build info: version: '3.141.59', revision: 'e82be7d358', time: '2018-11-14T08:25:48'
System info: os.name: 'Windows 10', os.arch: 'amd64', os.version: '10.0', java.version: '1.8.0_211'
Driver info: driver.version: ChromeDriver
at org.openqa.selenium.remote.service.DriverService.waitUntilAvailable(DriverService.java:202)
at org.openqa.selenium.remote.service.DriverService.start(DriverService.java:188)
at org.openqa.selenium.remote.service.DriverCommandExecutor.execute(DriverCommandExecutor.java:79)
at org.openqa.selenium.remote.RemoteWebDriver.execute(RemoteWebDriver.java:552)
at org.openqa.selenium.remote.RemoteWebDriver.startSession(RemoteWebDriver.java:213)
at org.openqa.selenium.remote.RemoteWebDriver.<init>(RemoteWebDriver.java:131)
at org.openqa.selenium.chrome.ChromeDriver.<init>(ChromeDriver.java:181)
at org.openqa.selenium.chrome.ChromeDriver.<init>(ChromeDriver.java:168)
at org.openqa.selenium.chrome.ChromeDriver.<init>(ChromeDriver.java:123)
at newpackage.PractAuto.main(PractAuto.java:10)
Caused by: org.openqa.selenium.net.UrlChecker$TimeoutException: Timed out waiting for [http://localhost:40026/status] to be available after 20002 ms
at org.openqa.selenium.net.UrlChecker.waitUntilAvailable(UrlChecker.java:100)
at org.openqa.selenium.remote.service.DriverService.waitUntilAvailable(DriverService.java:197)
... 9 more
Caused by: java.util.concurrent.TimeoutException
at java.util.concurrent.FutureTask.get(Unknown Source)
at com.google.common.util.concurrent.SimpleTimeLimiter.callWithTimeout(SimpleTimeLimiter.java:156)
at org.openqa.selenium.net.UrlChecker.waitUntilAvailable(UrlChecker.java:75)
... 10 more
My Code:
package newpackage;
import org.openqa.selenium.*;
import org.openqa.selenium.chrome.ChromeDriver;
public class PractAuto {
public static void main(String[] args) throws InterruptedException {
System.setProperty("webdriver.chrome.driver", "C:\\Program Files (x86)\\Google\\Chrome\\Application\\chrome.exe");
WebDriver driver = new ChromeDriver();
driver.manage().window().maximize();
driver.get("https://www.facebook.com/login/");
Thread.sleep(5000);
driver.findElement(By.name("email")).sendKeys("arunkumar3625#gmail.com");
driver.findElement(By.name("pass")).sendKeys("Password");
driver.findElement(By.id("loginbutton")).click();
driver.findElement(By.name("mercurymessages")).click();
driver.findElement(By.cssSelector("a[href*='https://www.facebook.com/messages/conversation-8148306']")).click();
}
Chrome browser is opening successfully but I'm getting the above error.
You can check the latest version for selenium and the webdrivers through this link
https://www.seleniumhq.org/download/
Also, you can share your code for better understanding of the error reason.
After checking your code, you are setting the property of the driver to a wrong path. Property webdriver.chrome.driver should be the chrome driver not the chrome executable file.
Download it from that link: https://www.seleniumhq.org/download/
Download latest chrome driver from https://www.seleniumhq.org/download/ and set property as :
System.setProperty("webdriver.chrome.driver","location of latest chrome driver")

Selenium WebDriverException: unknown error: call function result missing 'value' using Java

I am getting the below exception when i am trying to run my first test case using selenium webdriver in java. Can someone help me out plssss.....
Starting ChromeDriver 2.33.506120 (e3e53437346286c0bc2d2dc9aa4915ba81d9023f) on port 48523
Only local connections are allowed.
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.
Mar 29, 2018 7:34:16 AM org.openqa.selenium.remote.ProtocolHandshake createSession
INFO: Detected dialect: OSS
Exception in thread "main" org.openqa.selenium.WebDriverException: unknown error: call function result missing 'value'
(Session info: chrome=65.0.3325.181)
(Driver info: chromedriver=2.33.506120 (e3e53437346286c0bc2d2dc9aa4915ba81d9023f),platform=Windows NT 6.3.9600 x86_64) (WARNING: The server did not provide any stacktrace information)
Command duration or timeout: 31 milliseconds
Build info: version: '3.4.0', revision: 'unknown', time: 'unknown'
System info: host: 'NIL-MKODAGA-D13', ip: '172.16.20.242', os.name: 'Windows 8.1', os.arch: 'amd64', os.version: '6.3', java.version: '9.0.1'
Driver info: org.openqa.selenium.chrome.ChromeDriver
Capabilities [{applicationCacheEnabled=false, rotatable=false, mobileEmulationEnabled=false, networkConnectionEnabled=false, chrome= {chromedriverVersion=2.33.506120 (e3e53437346286c0bc2d2dc9aa4915ba81d9023f), userDataDir=C:\Users\mkodagan\AppData\Local\Temp\scoped_dir4652_10811}, takesHeapSnapshot=true, pageLoadStrategy=normal, databaseEnabled=false, handlesAlerts=true, hasTouchScreen=false, version=65.0.3325.181, platform=WIN8_1, browserConnectionEnabled=false, nativeEvents=true, acceptSslCerts=true, locationContextEnabled=true, webStorageEnabled=true, browserName=chrome, takesScreenshot=true, javascriptEnabled=true, cssSelectorsEnabled=true, setWindowRect=true, unexpectedAlertBehaviour=}]
Session ID: 1a39885769cc96406e2f2732c361c049
at java.base/jdk.internal.reflect.NativeConstructorAccessorImpl.newInstance0(Native Method)
at java.base/jdk.internal.reflect.NativeConstructorAccessorImpl.newInstance(Unknown Source)
at java.base/jdk.internal.reflect.DelegatingConstructorAccessorImpl.newInstance(Unknown Source)
at java.base/java.lang.reflect.Constructor.newInstance(Unknown Source)
at org.openqa.selenium.remote.ErrorHandler.createThrowable(ErrorHandler.java:215)
at org.openqa.selenium.remote.ErrorHandler.throwIfResponseFailed(ErrorHandler.java:167)
at org.openqa.selenium.remote.RemoteWebDriver.execute(RemoteWebDriver.java:671)
at org.openqa.selenium.remote.RemoteWebElement.execute(RemoteWebElement.java:272)
at org.openqa.selenium.remote.RemoteWebElement.sendKeys(RemoteWebElement.java:96)
at com.ham.scripts.ClickOnAllLinks.main(ClickOnAllLinks.java:44)
The error says it all :
Exception in thread "main" org.openqa.selenium.WebDriverException: unknown error: call function result missing 'value'
(Session info: chrome=65.0.3325.181)
(Driver info: chromedriver=2.33.506120 (e3e53437346286c0bc2d2dc9aa4915ba81d9023f),platform=Windows NT 6.3.9600 x86_64)
Build info: version: '3.4.0', revision: 'unknown', time: 'unknown'
System info: host: 'NIL-MKODAGA-D13', ip: '172.16.20.242', os.name: 'Windows 8.1', os.arch: 'amd64', os.version: '6.3', java.version: '9.0.1'
Driver info: org.openqa.selenium.chrome.ChromeDriver
The error clearly says that the Selenium Client and ChromeDriver is not getting detected back as in :
Build info: version: '3.4.0', revision: 'unknown', time: 'unknown'
Driver info: org.openqa.selenium.chrome.ChromeDriver
Your main issue is the version compatibility between the binaries you are using as follows :
You are using chromedriver=2.33
Release Notes of chromedriver=2.33 clearly mentions the following :
Supports Chrome v60-62
You are using chrome=65.0
Release Notes of ChromeDriver v2.37 clearly mentions the following :
Supports Chrome v64-66
Your Selenium Client version is 3.4.0 of which is a bit older.
So there is a clear mismatch between the Selenium Client v3.4.0 , ChromeDriver version (v2.33) and the Chrome Browser version (v65.0)
Solution
Upgrade Selenium to current levels Version 3.11.0.
Upgrade ChromeDriver to current ChromeDriver v2.37 level.
Keep Chrome version at Chrome v65.x levels. (as per ChromeDriver v2.37 release notes)
Clean your Project Workspace through your IDE and Rebuild your project with required dependencies only.
Use CCleaner tool to wipe off all the OS chores before and after the execution of your test Suite.
If your base Web Client version is too old, then uninstall it through Revo Uninstaller and install a recent GA and released version of Web Client.
Take a System Reboot.
Execute your #Test.
As mentioned by #DebanjanB, the problem lies with chromedriver version. From the logs you can see that it uses chromedriver=2.33.506120 which is bit old. Check for the latest version from "https://sites.google.com/a/chromium.org/chromedriver/downloads".
I was also facing the same problem the problem could be solved by updating the chrome driver.
You could uses below approaches for solving it.
Running npm install -g chromedriver
Manually updating the chromedriver, I found the chromedriver being used by the appium resides in below location.
C:\Users\User-Name\AppData\Local\appium-desktop\app-1.5.0\resources\app\node_modules\appium\node_modules\appium-chromedriver\chromedriver\win.
Replace this chromedriver with the latest one and run your code. It should work fine.
Note: The location could be OS specific, so search for chromedriver exact location.

Selenium chromeDriver crash “UnreachableBrowserException/

Hi I apologise for a repost but I am new to selenium and tried to launch this simple command to open youtube in a google. However, it keeps crashing and showing this error. Directly below is the code I am running.
System.setProperty("webdriver.chrome.driver",
"C:\\Program Files (x86)\\Google\\Chrome\\Application\\chrome.exe");
System.out.println(System.getProperty("webdriver.chrome.driver"));
WebDriver driver3 = new ChromeDriver();
driver3.get("https://www.youtube.com/");
Could anyone point me in the right direction of where I'm going wrong. Thank you
C:\Program Files (x86)\Google\Chrome\Application\chrome.exe
Exception in thread "main"
org.openqa.selenium.remote.UnreachableBrowserException: Could not start
a new session. Possible causes are invalid address of the remote server
or browser start-up failure.
Build info: version: 'unknown', revision: 'unknown', time: 'unknown'
System info: host: 'nuigit450', ip: '192.168.16.22', os.name: 'Windows
7', os.arch: 'amd64', os.version: '6.1', java.version: '1.8.0_111'
Driver info: driver.version: ChromeDriver
at org.openqa.selenium.remote.RemoteWebDriver.execute(RemoteWebDriver.java:622)
at org.openqa.selenium.remote.RemoteWebDriver.startSession(RemoteWebDriver.java:241)
at org.openqa.selenium.remote.RemoteWebDriver.<init>(RemoteWebDriver.java:128)
at org.openqa.selenium.remote.RemoteWebDriver.<init>(RemoteWebDriver.java:141)
at org.openqa.selenium.chrome.ChromeDriver.<init>(ChromeDriver.java:174)
at org.openqa.selenium.chrome.ChromeDriver.<init>(ChromeDriver.java:163)
at org.openqa.selenium.chrome.ChromeDriver.<init>(ChromeDriver.java:120)
at TestWeb.main(TestWeb.java:22)
Caused by: java.lang.IllegalStateException: The process has not exited yet therefore no result is available ...
at org.apache.commons.exec.DefaultExecuteResultHandler.getException(DefaultExecuteResultHandler.java:76)
at org.openqa.selenium.os.UnixProcess.checkForError(UnixProcess.java:173)
at org.openqa.selenium.os.CommandLine.checkForError(CommandLine.java:185)
at org.openqa.selenium.remote.service.DriverService.waitUntilAvailable(DriverService.java:177)
at org.openqa.selenium.remote.service.DriverService.start(DriverService.java:166)
at org.openqa.selenium.remote.service.DriverCommandExecutor.execute(DriverCommandExecutor.java:78)
at org.openqa.selenium.remote.RemoteWebDriver.execute(RemoteWebDriver.java:601)
... 7 more
Your webdriver.chrome.driver point to Chrome browser but it should point to chromedriver. For reference: https://sites.google.com/a/chromium.org/chromedriver/getting-started
You need to download chromedriver from here: https://sites.google.com/a/chromium.org/chromedriver/downloads and set path to this file in webdriver.chrome.driver.

PhantomjsDriver not working on both Windows and Linux

I have an application that uses Selenium Webdriver to get some information from a site. It works fine with FirefoxDriver and ChromeDriver, but when I tried to switch to PhantomJSDriver, I encountered some difficulties.
On a Windows machine , it starts normally, then immediately begins spitting out the following lines over and over again:
Jan 05, 2014 7:28:43 PM org.apache.http.impl.client.DefaultRequestDirector tryEx
ecute
INFO: I/O exception (org.apache.http.NoHttpResponseException) caught when processing request: The target server failed to respond
This is repeated probably several hundred times for about 10 minutes until it finally loads the page; sometimes it doesn't even manage to load it at all.
On a Linux machine, it tries to start, then returns the following:
Exception in thread "thread1"
org.openqa.selenium.remote.UnreachableBrowserException: Could not
start a new session. Possible causes are invalid address of the remote
server or browser start-up failure. Build info: version: 'unknown',
revision: 'unknown', time: 'unknown' System info: host: 'pangolin',
ip: '128.238.32.20', os.name: 'Linux', os.arch: 'amd64', os.version:
'2.6.32-39-generic', java.version: '1.7.0' Driver info:
driver.version: PhantomJSDriver
at org.openqa.selenium.remote.RemoteWebDriver.execute(RemoteWebDriver.java:548)
at org.openqa.selenium.remote.RemoteWebDriver.startSession(RemoteWebDriver.java:216)
at org.openqa.selenium.remote.RemoteWebDriver.(RemoteWebDriver.java:111)
at org.openqa.selenium.remote.RemoteWebDriver.(RemoteWebDriver.java:115)
at org.openqa.selenium.phantomjs.PhantomJSDriver.(PhantomJSDriver.java:107)
at org.openqa.selenium.phantomjs.PhantomJSDriver.(PhantomJSDriver.java:96)
Caused by: org.openqa.selenium.WebDriverException: Timed out waiting for driver
server to start. Build info: version: 'unknown', revision: 'unknown',
time: 'unknown' System info: host: 'pangolin', ip: '128.238.32.20',
os.name: 'Linux', os.arch: 'amd64', os.version: '2.6.32-39-generic',
java.version: '1.7.0' Driver info: driver.version: PhantomJSDriver
at org.openqa.selenium.remote.service.DriverService.start(DriverService.java:165)
at org.openqa.selenium.remote.service.DriverCommandExecutor.execute(DriverCommandExecutor.java:62)
at org.openqa.selenium.remote.RemoteWebDriver.execute(RemoteWebDriver.java:527)
... 7 more Caused by: org.openqa.selenium.net.UrlChecker$TimeoutException: Timed out waiting
for [http://localhost:16050/status] to be available after 20002 ms
at org.openqa.selenium.net.UrlChecker.waitUntilAvailable(UrlChecker.java:104)
at org.openqa.selenium.remote.service.DriverService.start(DriverService.java:163)
... 9 more Caused by: com.google.common.util.concurrent.UncheckedTimeoutException:
java.util.concurrent.TimeoutException
at com.google.common.util.concurrent.SimpleTimeLimiter.callWithTimeout(SimpleTimeLimiter.java:143)
at org.openqa.selenium.net.UrlChecker.waitUntilAvailable(UrlChecker.java:79)
... 10 more Caused by: java.util.concurrent.TimeoutException
at java.util.concurrent.FutureTask$Sync.innerGet(FutureTask.java:258)
at java.util.concurrent.FutureTask.get(FutureTask.java:119)
at com.google.common.util.concurrent.SimpleTimeLimiter.callWithTimeout(SimpleTimeLimiter.java:130)
... 11 more
What am I doing wrong? I've read a lot about how Phantomjs is so much faster than the other drivers, and would really like to use it, but if it takes 10 minutes to load each page, that's obviously not feasible.
I am running Selenium WebDriver version 2.38.0 and Phantomjs version 1.9.2.
Thank you very much in advance,
bsg
EDIT
Just to clarify, I don't think this has anything to do with my code; the errors on Linux are being thrown on the line where I try to start the PhantomJS driver, below.
DesiredCapabilities caps = new DesiredCapabilities();
caps.setJavascriptEnabled(true);
caps.setCapability(
PhantomJSDriverService.PHANTOMJS_EXECUTABLE_PATH_PROPERTY,
phantombinary//"/home/p/phantomjs-1.9.2-linux-x86_64/bin/phantomjs"
);
// Launch driver (will take care and ownership of the phantomjs process)
WebDriver driver = new PhantomJSDriver(caps);
System.out.println("starting driver");
If it is still not working for you on Linux, try below piece of code, it is working for me on Mac.
capabilities.setCapability("phantomjs.binary.path", "path of phantom binary/phantomjs")
org.openqa.selenium.remote.UnreachableBrowserException clearly something to do with Phantom. On Windows ensure Phantom is running (Set Environment variable and add PATH)
Check that Remote Machine hub address is correct and you should be able to run phantomjs.
Note: Selenium Server must be running on the desired remote machine.
DesiredCapabilities phantomBeast = DesiredCapabilities.phantomjs();
try {
webDriverInstance = new RemoteWebDriver(new URL(hubUrl), phantomBeast);
} catch (Exception e) {
//Do something
}

Categories