Selenium Standalone fails to run tests in Google Chrome [duplicate] - google-chrome

This question already has answers here:
How to run Google Chrome with Selenium RC?
(5 answers)
Closed 9 years ago.
I'm using jenkins to run selenium standalone server and html test suites in a windows xp node.
I've managed to get it running and working for iexplore and firefox, but when it comes to googlechrome it fails in starting it.
This is the command I use to run the tests in googlechrome:
java -jar C:\...\selenium-server-standalone-2.28.0.jar -htmlSuite "*googlechrome C:\Program Files\Google\Chrome\Application\chrome.exe --allow-file-access-from-files –-disable-web-security" file:///C:/WebTest/Tests/ C:/WebTest/Tests/TestSuite.html C:\jenkins\workspace\sp-webTest\resultados\resultadoGC.html
And the error I get is:
12:43:08.044 INFO - Launching Google Chrome...
HTML suite exception seen:
java.lang.NullPointerException
at org.openqa.selenium.server.browserlaunchers.GoogleChromeLauncher.createCommandArray(GoogleChromeLauncher.java:168)
at org.openqa.selenium.server.browserlaunchers.GoogleChromeLauncher.launch(GoogleChromeLauncher.java:82)
at org.openqa.selenium.server.browserlaunchers.AbstractBrowserLauncher.launchHTMLSuite(AbstractBrowserLauncher.java:47)
at org.openqa.selenium.server.htmlrunner.HTMLLauncher.runHTMLSuite(HTMLLauncher.java:145)
at org.openqa.selenium.server.htmlrunner.HTMLLauncher.runHTMLSuite(HTMLLauncher.java:196)
at org.openqa.selenium.server.SeleniumServer.runHtmlSuite(SeleniumServer.java:611)
at org.openqa.selenium.server.SeleniumServer.boot(SeleniumServer.java:285)
at org.openqa.selenium.server.SeleniumServer.main(SeleniumServer.java:243)
at org.openqa.grid.selenium.GridLauncher.main(GridLauncher.java:54)
Any help will be appreciated.

Specifying the webdriver in java helps.
System.setProperty("webdriver.chrome.driver", "c:/chromedriver.exe");
driver = new ChromeDriver();
Download link for chrome driver http://code.google.com/p/chromedriver/downloads/list

I got it working, somehow sending flags to chrome in the command causes selenium to throw null pointer exception. So what I did was add chrome to the PATH in mi xp node, use Selenium plugin to run html test suites in jenkins and specify a start url that begins with "https://" using google chrome and a start url that begins with "file:///" was a mess and couldn't get it to work like that. I also added the -trustAllSSLCertificates in "others" input box.

For me on Windows it work:
java -jar "c:\selenium-server-standalone-2.35.0.jar" -forcedBrowserMode "*googlechrome c:\Program Files\Google\Chrome\Application\chrome.exe"

Related

Chrome headless not completing, ever (Windows)

I'm struggling to get Chrome headless to do absolutely anything.
I've tried the simple 'getting started' here: https://developers.google.com/web/updates/2017/04/headless-chrome
This example: chrome --headless --disable-gpu --screenshot https://www.chromestatus.com/
does nothing for me. No screenshot generated in the folder. (Was running CMD as Admin).
I've created a webapp (running in IIS on my PC) and set a breakpoint on its Index page. When I call the app using Chrome headless the breakpoint is triggered, but my 2nd (Console) app which created the Chrome headless instance never proceeds beyond the 'Navigate()' line.
The code from the console app:
IWebDriver webClient;
ChromeOptions option = new ChromeOptions();
option.AddArguments("--headless", "--disable-gpu", "--window-size=1920,1200", "--ignore-certificate-errors", "--no-sandbox");
webClient = new ChromeDriver(option);
webClient.Navigate().GoToUrl("http://localhost:49709/");
((ITakesScreenshot)webClient).GetScreenshot().SaveAsFile("ChromeScreenshot.png", ScreenshotImageFormat.Png);
Running:
Windows 7 64-bit
Chrome 64-bit 66.0.3359.139
ChromeDriver 2.38
What am I missing?
I've figured out what is causing the issue, but not why or a proper fix for it. Writing this here in case it helps someone in future.
I found by chance that a timeout error would eventually be thrown after 60 seconds:
The HTTP request to the remote WebDriver server for URL http://localhost:51660/session timed out after 60 seconds.
This error was being thrown on the creation of the ChromeDriver object. Note this is an error thrown by Selenium trying to communicate with the Chrome WebDriver, NOT the Navigate() command failing.
I discovered by complete chance that by removing the "--headless" parameter from the options makes everything works fine. I also found that another parameter "--remote-debugging-port=9222" causes it to fail completely, too.
I'm currently assuming these issues are specific to my environment rather than a bug in the ChromeDriver. But, still looking.

"Unable to move the cache" error in selenium webdriver

While running the selenium webdriver script for chrome browser, I am getting the below error:
[2144:7568:0519/130434:ERROR:cache_util_win.cc(20)] Unable to move the cache: 0
[2144:7568:0519/130434:ERROR:cache_util.cc(134)] Unable to move cache folder C:\Users\Prudvi\AppData\Local\Google\Chrome\User Data\ShaderCache\GPUCache to C:\Users\Prudvi\AppData\Local\Google\Chrome\User Data\ShaderCache\old_GPUCache_000
[2144:7568:0519/130434:ERROR:cache_creator.cc(129)] Unable to create cache
[2144:7568:0519/130434:ERROR:shader_disk_cache.cc(589)] Shader Cache Creation failed: -2
Could some one help me out please
I assume you're starting your chrome driver attaching your default profile.
It's not the problem of your chrome driver, It's because you are running another chrome instance while you are starting your selenium webdriver, so some of the files in the profile is locked so that your selenium webdriver can not move it.
I encountered the same problem and shut down all chrome instances before starting my selenium webdriver solved the problem.
It is a problem with chrome driver installation. After I installed the chrome driver it worked for me. Thanks
This problem occurs due to the chormedriver api is not integrated with your project.
JUST DO THESE STEPS:
Configure your chormedriver api in your build path ( download from here http://chromedriver.storage.googleapis.com/index.html)
2.Go to the project right click ->>> go to build path ---> conf build path --> libraries --> add jar (add chromedriver jar file)
now add this code before the chormdriver object call.
System.setProperty("webdriver.chrome.driver", "path for your chormedriver api ");
It's because you must install selenium web driver instead of selenium IDE, download both & configure build path with that jar file.
Double check the import files which corresponds to selenium web driver, not selenium IDE.

Selenium Standalone + Chrome driver, add capabilities from command line

I want to run some test using selenium standalone server on Google Chrome but i need to pass some ChromeOptions to the chrome driver from command line
Anybody has an idea of how can i do that?
Selenium Core, which is what you are referring to, was released before Chrome existed. Support for Chrome was added later. What you are asking for was never supported, and with Selenium Core deprecated several years back, it will probably never be supported.
One possible workaround is to set the desired options in the Chrome profile.
Another options, although much more painful, is to move up to Selenium WebDriver.

Selenium WebDriver, Chrome. I am getting errors NOT IMPLEMENTED during (in the beginning and ending) running Python tests

Errors:
[6944:3028:0128/220426:ERROR:chrome_views_delegate.cc(176)] NOT IMPLEMENTED
[6944:3028:0128/220426:ERROR:desktop_root_window_host_win.cc(746)] NOT IMPLEMENT
ED
[6944:3028:0128/220430:ERROR:desktop_root_window_host_win.cc(746)] NOT IMPLEMENT
Read that the problem is in versions of Google Chrome and chromedriver.exe but I have the last version of Google Chrome - 32.0.1700.102 m and chromedriver.exe - 2.8.
Test runs fine.
That's just the console output from ChromeDriver, which does't indicate anything wrong with the tests. You can silence these outputs in order to avoid them on the console. Refer this link: Silencing Chrome driver console outputs when I run my tests.

Running Chrome WebDriver on a linux server with no display

I'd like to run automated tests using selenium2's chrome webdriver on a linux server.
I've already set up firefox to run on the server by using Xvfb (See http://www.semicomplete.com/blog/geekery/xvfb-firefox.html) and would like to do something similar with chrome. Is this possible?
I was facing the same challenge of setting a linux box with selenium + chromedriver,
and here's my notes:
Pre-reqs:
Install JRE to run the selenium jar
Install the selenium server
grab the jar file from https://code.google.com/p/selenium/downloads/list)
Install xvfb (you've seem to have already achieved this part)
Install google-chrome for your linux distribution
Download the chrome driver
You can grab it from here: https://sites.google.com/a/chromium.org/chromedriver/downloads
Install other selenium dependencies that you might need (but the above is the minimum to get chromedriver to work)
To run:
Run xvfb
Xvfb :1 -screen 5 1024x768x8 &
export DISPLAY=:1.5
Run the selenium server jar with ChromeDriver options.
It'll look something like this:
java -jar selenium-server-standalone-2.30.0.jar -Dwebdriver.chrome.bin=/path/to/google-chrome -Dwebdriver.chrome.driver=/path/to/chromedriver
The selenium server log should output something similar to this:
Mar 19, 2013 10:07:27 AM org.openqa.grid.selenium.GridLauncher main
INFO: Launching a standalone server
Setting system property webdriver.chrome.bin to {location of google-chrome}
Setting system property webdriver.chrome.driver to {location of chromedriver}
10:07:34.258 INFO - RemoteWebDriver instances should connect to: http://127.0.0.1:4444/wd/hub
10:07:34.259 INFO - Version Jetty/5.1.x
10:07:34.259 INFO - Started HttpContext[/selenium-server/driver,/selenium-server/driver]
...
Reference:
http://www.yann.com/en/use-xvfb-selenium-and-chrome-to-drive-a-web-browser-in-php-23/08/2012.html
Cheers!
According to SetEnvironmentProperty to ChromeDriver programatically you can do the following:
service = new ChromeDriverService.Builder()
.usingChromeDriverExecutable(new File("/path/to/chromedriver"))
.usingAnyFreePort()
.withEnvironment(ImmutableMap.of("DISPLAY",":20"))
.build();
Here is the documentation for withEnvironment
I haven't been able to find a way to do this programmatically for the ChromeDriver like you can with the FirefoxBinary.
I've submitted a improvement request which has a patch attached to allow this. You can see it here: http://code.google.com/p/selenium/issues/detail?id=2673
Edit:
You can see below response from Stephen on how to use this now the change has been merged.: https://stackoverflow.com/a/16619608/998442
I get what you are trying to do, but you probably just run selenium grid. It was made for automated browser testing. Works great on a server.
https://www.selenium.dev/documentation/en/grid/