Unable to start Chrome browser with user profile in Selenium - java

I am trying to open a Chrome browser window with an existing user profile.
String dir= "/Users/labuser/Library/Application Support/Google/Chrome";
ChromeOptions options = new ChromeOptions();
options.addArguments("--user-data-dir="+dir);
driver = new ChromeDriver(options); // throws an exception!
I confirmed the user directory path by looking at chrome://version page. (screenshot below)
Due to some reason, this code throws an exception with very less information
org.openqa.selenium.WebDriverException: unknown error: Chrome failed to start: exited abnormally
(Driver info: chromedriver=2.33.506106 (8a06c39c4582fbfbab6966dbb1c38a9173bfb1a2),platform=Mac OS X 10.12.6 x86_64) (WARNING: The server did not provide any stacktrace information)
Command duration or timeout: 60.33 seconds
Build info: version: '2.53.0', revision: '35ae25b', time: '2016-03-15 17:00:58'
System info: host: 'arustagi-wx-3', ip: '10.41.25.35', os.name: 'Mac OS X', os.arch: 'x86_64', os.version: '10.12.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:148)
Edit
I am using the following chrome browser, this falls in the supported range of browsers
Version 61.0.3163.100

You are using the latest version of the ChromeDriver
chromedriver=2.33.506106
with Selenium 2.53. You should use the latest release.
Anyway, what is your browser version? Here you can take a look which are the browsers version supported (based on your chromedriver).
EDIT
I tried with:
Selenium 3.5.3
ChromeDriver v2.33
Google Chrome Version 62.0.3202.62 (Official Build) (64-bit)
From chrome://version/, my profile path is
/Volumes/MacintoshSSD/Users/DurdenP/Library/Application Support/Google/Chrome/Default
Trying
String chromeDriver ="pathTo/ChromeDriver/chromedriver";
System.setProperty("webdriver.chrome.driver", chromeDriver);
ChromeOptions options = new ChromeOptions();
String dir= "/Volumes/MacintoshSSD/Users/DurdenP/Library/Application Support/Google/Chrome";
options.addArguments("user-data-dir="+dir);
ChromeDriver driver = new ChromeDriver(options);
it works.

Finally got this fixed. I was working on macOS and found out that i needed to quit the browser cleanly.
After closing the browser window, i had to right click on the icon in the dock and press quit. The selenium script would work perfectly fine after this.

Related

How to solve sessionnotcreated issue in Selenium webdriver for Chrome browser?

I am trying to launch Chrome browser but getting an error of "session not created" in Selenium. It research on it and I found if the browser and Chrome driver is not compatible then we will get such issue, so download the latest version of Chrome Driver i.e. Chrome Driver 2.45 which is compatible with v70-72.
So I have downloaded browser version 70.0.3538.67, but still I am unable to launch the Chrome browser and getting the same error. I am using Eclipse 2018-09 and selenium-server-standalone-3.141.59. Below is my code and error message:
Code:-
import org.openqa.selenium.WebDriver;
import org.openqa.selenium.chrome.ChromeDriver;
public class open_browser {
public WebDriver driver;
public void aa1() {
System.setProperty("webdriver.chrome.driver", "F:\\Selenium
files\\chromedriver.exe");
driver= new ChromeDriver();
driver.get("google.com");
}
public static void main(String[] args) {
// TODO Auto-generated method stub
open_browser ob=new open_browser();
ob.aa1();
}
}
Error message:-
Starting ChromeDriver 2.45.615291
(ec3682e3c9061c10f26ea9e5cdcf3c53f3f74387)
on port 48165
Only local connections are allowed.
Exception in thread "main" >org.openqa.selenium.SessionNotCreatedException:
session not created
from disconnected: unable to connect to renderer
(Session info: chrome=70.0.3538.67)
(Driver info: chromedriver=2.45.615291
(ec3682e3c9061c10f26ea9e5cdcf3c53f3f74387),platform=Windows NT 6.1.7601 SP1
x86_64) (WARNING: The server did not provide any stacktrace information)
Command duration or timeout: 3.56 seconds
Build info: version: '2.53.1', revision: 'a36b8b1', time: '2016-06-30
17:32:46'
System info: host: 'aspirehp-PC', ip: '192.168.43.104', os.name: 'Windows
7', os.arch: 'amd64', os.version: '6.1', java.version: '1.8.0_191'
Driver info: org.openqa.selenium.chrome.ChromeDriver
at sun.reflect.NativeConstructorAccessorImpl.newInstance0(Native Method)
at sun.reflect.NativeConstructorAccessorImpl.newInstance(Unknown Source)
at sun.reflect.DelegatingConstructorAccessorImpl.newInstance(Unknown Source)
at java.lang.reflect.Constructor.newInstance(Unknown Source)
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.(RemoteWebDriver.java:131)
at org.openqa.selenium.remote.RemoteWebDriver.(RemoteWebDriver.java:144)
at org.openqa.selenium.chrome.ChromeDriver.(ChromeDriver.java:170)
at org.openqa.selenium.chrome.ChromeDriver.(ChromeDriver.java:159)
at org.openqa.selenium.chrome.ChromeDriver.(ChromeDriver.java:116)
at practise.open_browser.aa1(open_browser.java:10)
at practise.open_browser.main(open_browser.java:17)
Go for all latest one's.
Latest chrome browser (as admin to system, generally install in C:\Program Files (x86))
Latest chromedriver http://chromedriver.chromium.org/downloads presently ChromeDriver 2.45
Latest webdriver https://www.seleniumhq.org/download/ presently 3.141.59
Also update the get, need to provide complete URL , like
System.setProperty("webdriver.chrome.driver", "E:\\workspace\\Training\\drivers\\chromedriver.exe");
WebDriver driver=new ChromeDriver();
driver.get("http://www.google.com");

Unable to run Headless Chrome Browser on Linux Machine using Selenium Webdriver java

Used Selenium Webdriver(V2.29), selenium-api version(3.4.0), Chrome
Version (62.0.3202.94) 64 bit and tried to run chrome browser in linux machine with the below code.
WebDriver driver;
String chromeBinaryPath = "/data/Package/CHROME_NEW";
String driverPath = "/data/Package/Selenium/WebDrivers/ChromeDrivers/chromedriver_linux32/chromedriver";
System.setProperty("webdriver.chrome.driver", driverPath);
System.setProperty("webdriver.chrome.verboseLogging","true");
System.setProperty("webdriver.chrome.logfile","/data/Package/log/chromedriver.log");
ChromeOptions optionsLinux64 = new ChromeOptions();
optionsLinux64.setBinary(chromeBinaryPath);
optionsLinux64.addArguments("--headless");
optionsLinux64.addArguments("--no-sandbox");
optionsLinux64.addArguments("--disable-gpu");
optionsLinux64.addArguments("--headless");
driver = new ChromeDriver(optionsLinux64);
When tried to create a chrome session, getting below exception:
unknown error: Chrome failed to start: exited abnormally (Driver info: chromedriver=2.29.461571 (8a88bbe0775e2a23afda0ceaf2ef7ee74e822cc5),platform=Linux 3.10.0-693.5.2.el7.x86_64 x86_64) (WARNING: The server did not provide any stacktrace information) Command duration or timeout: 60.10 seconds Build info: version: '3.4.0', revision: 'unknown', time: 'unknown' System info: host: 'el4014.bc', ip: '10.120.94.70', os.name: 'Linux', os.arch: 'amd64', os.version: '3.10.0-693.5.2.el7.x86_64', java.version: '1.8.0_151' Driver info: driver.version: ChromeDriver
Installed Chrome at /data/Package/CHROME_NEW folder using rpm file.
Message in chromedriver.log:
[0.204][DEBUG]: DevTools request: http://localhost:12111/json/version
LaunchProcess: failed to execvp:
/data/Package/CHROME_NEW/
[0.379][DEBUG]: DevTools request failed
Can anyone help me in resolving with the above issue.
This should be work:
ChromeOptions options = new ChromeOptions();
options.setHeadless(true);
Try adding window size
optionsLinux64.addArguments("window-size=1024x780");

How to run selenium tests on chrome if only binary file of chrome is placed in a server location in E drive

I have a situation in my project as below :
My code was executing as expected till the IT admin uninstalled chrome and FF from Jenkins server.
After raising a concern they placed a chrome binary in E drive .( E:\GC Local\GoogleChrome).But Chrome is not installed anywhere
I am facing issues to resolve this.
Do anyone guide here ?
Code I used :
if ("chrome".equals(browser))
{
System.setProperty("webdriver.chrome.driver",
System.getProperty("user.dir")
+ "\\src\\test\\resources\\drivers\\chromedriver.exe");
ChromeOptions options = new ChromeOptions();
options.addArguments("--disable-extensions");
options.addArguments("--start-maximized");
driver = new ChromeDriver(options);
}
Will it work for you ?
ChromeOptions options = new ChromeOptions();
options.setBinary("E:\\GC Local\\GoogleChrome");
I understand that in homepath \app data chrome should be installed by default to run chrome tests. In my case , there is no chrome istalled in homepath-app but in E drive
When I used the below code :
ChromeOptions options = new ChromeOptions();
options.setBinary("E:\\GCLocal\\GoogleChrome\\GoogleChromePortable.exe");
// System.setProperty("webdriver.chrome.driver", "C:\\Selenium\\Browsers\\chromedriver.exe");
System.setProperty("webdriver.chrome.driver",
System.getProperty("user.dir")
+ "\\src\\test\\resources\\drivers\\chromedriver.exe");
driver = new ChromeDriver(options);
I am getting getting the following :
T E S T S
Running TestSuite
Browser :chrome
Starting ChromeDriver 2.29.461591 (62ebf098771772160f391d75e589dc567915b233) on port 45594
Only local connections are allowed.
Error in initializing the Test .Details :-
org.openqa.selenium.WebDriverException: unknown error: Chrome failed to start: exited normally
(Driver info: chromedriver=2.29.461591 (62ebf098771772160f391d75e589dc567915b233),platform=Windows NT 6.1.7601 SP1 x86_64) (WARNING: The server did not provide any stacktrace information)
Command duration or timeout: 62.74 seconds
Build info: version: '2.53.0', revision: '35ae25b1534ae328c771e0856c93e187490ca824', time: '2016-03-15 10:43:46'
System info: host: 'WHIS2002', ip: '10.192.129.112', os.name: 'Windows Server 2008 R2', os.arch: 'amd64', os.version: '6.1', java.version: '1.8.0_77'
Driver info: org.openqa.selenium.chrome.ChromeDriver
./TestReport.html
The above approach is correct. My issue was that portable-chrome binary refused to open due to some issues in server .code was fine.
This happened because of portable chrome binary performance issues which I solved like this :
Google Chrome Portable may run slowly from some flash drives. You can speed this up by copying GoogleChromePortable.ini from the GoogleChromePortable\Other\Source directory to the GoogleChromePortable directory and editing it to set RunLocally=true. If you do so, be sure to allow Google Chrome Portable time to copy your profile back after shutting it down. Of course, there are privacy implications to copying your personal data locally to a PC not under your control.
Thanks

Microsoft Edge: org.openqa.selenium.remote.SessionNotFoundException: null

Automating tests to edge browser through webDriver using java script.
System.setProperty("webdriver.edge.driver",
"C:\\Program Files (x86)\\Microsoft Web Driver\\MicrosoftWebDriver.exe");
WebDriver driver = new EdgeDriver();
Already install MicrosoftWebDriver
And using selenium webdriver 2.48.2
OS: Microsoft Windows [Version 10.0.10565]
But got and Exception:
Exception in thread "main"
org.openqa.selenium.remote.SessionNotFoundException: null (WARNING: The server did not provide any stacktrace information)
Command duration or timeout: 2.14 seconds
Build info: version: '2.48.2', revision: '41bccdd10cf2c0560f637404c2d96164b67d9d67', time: '2015-10-09 13:08:06'
System info: host: 'DESKTOP-DUHBOA4', ip: '192.168.31.26', os.name: 'Windows 8.1', os.arch: 'amd64', os.version: '6.3', java.version: '1.8.0_45'
Driver info: org.openqa.selenium.edge.EdgeDriver
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:422)
at org.openqa.selenium.remote.ErrorHandler.createThrowable(ErrorHandler.java:206)
at org.openqa.selenium.remote.ErrorHandler.throwIfResponseFailed(ErrorHandler.java:164)
at org.openqa.selenium.remote.RemoteWebDriver.execute(RemoteWebDriver.java:647)
at org.openqa.selenium.remote.RemoteWebDriver.startSession(RemoteWebDriver.java:247)
at org.openqa.selenium.remote.RemoteWebDriver.<init>(RemoteWebDriver.java:129)
at org.openqa.selenium.remote.RemoteWebDriver.<init>(RemoteWebDriver.java:142)
at org.openqa.selenium.edge.EdgeDriver.<init>(EdgeDriver.java:152)
at org.openqa.selenium.edge.EdgeDriver.<init>(EdgeDriver.java:141)
at org.openqa.selenium.edge.EdgeDriver.<init>(EdgeDriver.java:98)
at test.edge.browser.UseEdgeBrowser.main(UseEdgeBrowser.java:18)
No clue for this. Do I still need to configure something?
There are 2 kinds of
1. Microsoft WebDriver: https://www.microsoft.com/en-us/download/details.aspx?id=48212
and
WebDriver for Windows Insiders: http://www.microsoft.com/en-us/download/details.aspx?id=48740
using 1 with this issue. using 2 works for me
It's some time ago, but here is the solution for everyone with the same error..
Your Windows build must be equal to the Microsoft WebDriver version(eg 14393). Just open start menu, type in "winver" and use the correct WebDriver (right hand side) on following page:
https://developer.microsoft.com/en-us/microsoft-edge/tools/webdriver/

Chromedriver failing on Jenkins (Linux)

I am trying to run UI tests on Chrome on Jenkins, and from the error it appears that it is failing to start.
org.openqa.selenium.WebDriverException: chrome not reachable
(Driver info: chromedriver=2.14.313457 (3d645c400edf2e2c500566c9aa096063e707c9cf),platform=Linux 2.6.32-358.el6.x86_64 x86_64) (WARNING: The server did not provide any stacktrace information)
Command duration or timeout: 60.54 seconds (user: 'UnknownUser-0', output: '1440016601647')
Build info: version: '2.45.0', revision: '5017cb8e7ca8e37638dc3091b2440b90a1d8686f', time: '2015-02-27 09:10:26'
System info: host: 'abc.xyz.com', ip: '111.222.333.444', os.name: 'Linux', os.arch: 'amd64', os.version: '2.6.32-358.el6.x86_64', java.version: '1.8.0_05'
Driver info: org.openqa.selenium.chrome.ChromeDriver
at java.lang.reflect.Constructor.newInstance(Constructor.java:408)
at org.openqa.selenium.remote.ErrorHandler.createThrowable(ErrorHandler.java:204)
at org.openqa.selenium.remote.ErrorHandler.throwIfResponseFailed(ErrorHandler.java:156)
at org.openqa.selenium.remote.RemoteWebDriver.execute(RemoteWebDriver.java:599)
at org.openqa.selenium.remote.RemoteWebDriver.startSession(RemoteWebDriver.java:240)
at org.openqa.selenium.remote.RemoteWebDriver.<init>(RemoteWebDriver.java:126)
at org.openqa.selenium.remote.RemoteWebDriver.<init>(RemoteWebDriver.java:139)
at org.openqa.selenium.chrome.ChromeDriver.<init>(ChromeDriver.java:171)
at org.openqa.selenium.chrome.ChromeDriver.<init>(ChromeDriver.java:139)...
The code (in Java) simply tries to instantiate a default instance of Chromedriver, and fails. The following message also shows in the log, which confuses me. It appears that the driver is opening, but stopping immediately?
Starting ChromeDriver 2.14.313457 (3d645c400edf2e2c500566c9aa096063e707c9cf) on port 4601
Only local connections are allowed.
[0.422][WARNING]: PAC support disabled because there is no system implementation
Starting ChromeDriver 2.14.313457 (3d645c400edf2e2c500566c9aa096063e707c9cf) on port 9515
Only local connections are allowed.
The instantiation is done as:
WebDriver webDriver = null;
String chromeDriverLocation = MyCustomPropertyReader.getProperty("webdriver.chrome.binary.location");
System.setProperty("webdriver.chrome.driver", chromeDriverLocation);
final DesiredCapabilities capabilities = DesiredCapabilities.chrome();
webDriver = new ChromeDriver(capabilities);
I am able to run the Chromedriver from the command prompt, and I have also checked that all the environment variables that are needed to load it up and indeed available during the instantiation.
Could someone tell me what I might be missing, or if there is a way to obtain more information about the cause of this failure?
The issue was resolved by updating the browser installation, and making sure that both Chromedriver and the Chrome browser can be run from the command prompt.

Categories

Resources