Failed to start new browser session: org.openqa.selenium.server.RemoteCommandException: Error while launching browser on session null - selenium

09:39:51.984 INFO - Got result: Failed to start new browser session: org.openqa.selenium.server.RemoteCommandException: Error while launching browser on session null
09:39:52.002 INFO - Command request: getNewBrowserSession[*firefox, http://website.localhost] on session null
09:39:52.002 INFO - creating new remote session
09:39:52.003 INFO - Allocated session 4b3951d894ed4a2c94b7fd9758cd5554 for http://website.localhost, launching...
jar:file:/usr/bin/selenium-server-standalone-2.41.0.jar!/customProfileDirCUSTFFCHROME
09:39:52.071 INFO - Preparing Firefox profile...
09:40:12.129 ERROR - Failed to start new browser session, shutdown browser and clear all session data
java.lang.RuntimeException: Timed out waiting for profile to be created!
at org.openqa.selenium.server.browserlaunchers.FirefoxChromeLauncher.waitForFullProfileToBeCreated(FirefoxChromeLauncher.java:307)
at org.openqa.selenium.server.browserlaunchers.FirefoxChromeLauncher.populateCustomProfileDirectory(FirefoxChromeLauncher.java:119)
at org.openqa.selenium.server.browserlaunchers.FirefoxChromeLauncher.launch(FirefoxChromeLauncher.java:89)
at org.openqa.selenium.server.browserlaunchers.FirefoxChromeLauncher.launchRemoteSession(FirefoxChromeLauncher.java:346)
at org.openqa.selenium.server.browserlaunchers.FirefoxLauncher.launchRemoteSession(FirefoxLauncher.java:114)
at org.openqa.selenium.server.BrowserSessionFactory.createNewRemoteSession(BrowserSessionFactory.java:400)
at org.openqa.selenium.server.BrowserSessionFactory.getNewBrowserSession(BrowserSessionFactory.java:144)
at org.openqa.selenium.server.BrowserSessionFactory.getNewBrowserSession(BrowserSessionFactory.java:105)
at org.openqa.selenium.server.SeleniumDriverResourceHandler.getNewBrowserSession(SeleniumDriverResourceHandler.java:809)
at org.openqa.selenium.server.SeleniumDriverResourceHandler.doCommand(SeleniumDriverResourceHandler.java:435)
at org.openqa.selenium.server.SeleniumDriverResourceHandler.handleCommandRequest(SeleniumDriverResourceHandler.java:405)
at org.openqa.selenium.server.SeleniumDriverResourceHandler.handle(SeleniumDriverResourceHandler.java:151)
at org.openqa.jetty.http.HttpContext.handle(HttpContext.java:1526)
at org.openqa.jetty.http.HttpContext.handle(HttpContext.java:1479)
at org.openqa.jetty.http.HttpServer.service(HttpServer.java:920)
at org.openqa.jetty.http.HttpConnection.service(HttpConnection.java:820)
at org.openqa.jetty.http.HttpConnection.handleNext(HttpConnection.java:986)
at org.openqa.jetty.http.HttpConnection.handle(HttpConnection.java:837)
at org.openqa.jetty.http.SocketListener.handleConnection(SocketListener.java:243)
at org.openqa.jetty.util.ThreadedServer.handle(ThreadedServer.java:358)
at org.openqa.jetty.util.ThreadPool$PoolThread.run(ThreadPool.java:537)
09:40:12.131 INFO - Got result: Failed to start new browser session: org.openqa.selenium.server.RemoteCommandException: Error while launching browser on session null
09:40:12.143 INFO - Command request: getNewBrowserSession[*firefox, http://website.localhost] on session null
what i am doing ?
Step 1: Start the hub
The Hub is the central point that will receive all the test request and distribute them the the right nodes.
Open a command prompt and navigate to the directory where you copied the selenium-server-standalone file. Type the following command:
java -jar selenium-server-standalone-2.14.0.jar -role hub
Step 2: Start the nodes
Regardless on whether you want to run a grid with new WebDriver functionality, or a grid with Selenium 1 RC functionality, or both at the same time, you use the same selenium-server-standalone jar file to start the nodes.
java -jar selenium-server-standalone-2.14.0.jar -role node -hub http://localhost:44444/grid/register (here 44444 is for the environment i am working)

This is due to compatibility issues between selenium and firefox.
You need to upgrade to the latest selenium server, 2.44 at the moment.

Yes! As alec[xe suggested this is due to the compatibility issues between firefox and selenium. For firefox version higher than 30 you must use selenium 2.44 version.Here's the changelog of the selenium please take a look and decide which version of the selenium will fulfill your requirement.
Click here to download the latest(2.44) version of the selenium.

Related

Jenkins starts chromedriver in background mode (like headless mode)

I've setup Jenkins server on windows 10 machine. When running the job(simply mvn test -DsuiteXmlFile=%TestSuite%) the job successfully compiles and starts tests. I can see first being skipped, second failed and then it starts passing one after one. No Chrome window is opened, but when I check in task manager I can see it opens several Chrome processes in background. When calling mvn test -DsuiteXmlFile=TestSuite in CMD(also in power shell) it opens Chrome in front.
Looking at Jenkins logs I see that it creates a .bat file in c:/System/TEMP/ directory and executes that batch file. I've even tried to copy the file, put in my project's root and call it via CMD, the same .bat file works as expected. Still jenkins opens Chrome in background. Any idea what causes this and how can I force Jenkins to run tests in Foreground?
My chromedriver vesion is 78.0.3904.70(if needed).
Logs are identical for both cases:
[INFO] -------------------------------------------------------
[INFO] T E S T S
[INFO] -------------------------------------------------------
[INFO] Running TestSuite
SLF4J: Failed to load class "org.slf4j.impl.StaticLoggerBinder".
SLF4J: Defaulting to no-operation (NOP) logger implementation
SLF4J: See http://www.slf4j.org/codes.html#StaticLoggerBinder for further details.
18.11.2019 03:50:38.019 INFO - [AutomationListener]:Staring to run test suite with 11 tests
Nov 18, 2019 3:50:38 AM org.openqa.selenium.remote.DesiredCapabilities chrome
INFO: Using `new ChromeOptions()` is preferred to `DesiredCapabilities.chrome()`
Starting ChromeDriver 78.0.3904.70 (edb9c9f3de0247fd912a77b7f6cae7447f6d3ad5-refs/branch-heads/3904#{#800}) on port 39924
Only local connections are allowed.
Please protect ports used by ChromeDriver and related test frameworks to prevent access by malicious code.
[1574077841.726][WARNING]: Timed out connecting to Chrome, retrying...
Nov 18, 2019 3:50:43 AM org.openqa.selenium.remote.ProtocolHandshake createSession
INFO: Detected dialect: W3C
[1574077845.835][WARNING]: Timed out connecting to Chrome, retrying...
18.11.2019 03:50:55.489 INFO - [BasePage]:The element: By.cssSelector: polygon is clicked
18.11.2019 03:50:55.494 INFO - [AutomationListener]:----------------------------------------------------------------------
18.11.2019 03:50:55.495 INFO - [AutomationListener]:Starting to run TestMethod test method
18.11.2019 03:50:55.495 INFO - [AutomationListener]:----------------------------------------------------------------------
When the Jenkins slave run as service in the background every program it initiate, like running the batch file, will also be in the background. The solution is to run the Jenkins slave as a regular program in the foreground.
Yes, the slave solution is working in my case.
I have also a window machine, I have configured the Jenkins and also configured the slave within the machine and now it every time opens the browser in the foreground.
I know it's not the genuine solution but it works perfectly

Unable to define maxInstances when launching hub via Selenium 3.0.0 beta3

I've been using the selenium-server-standalone-2.53.0.jar and recently tried to upgrade to version 3.0.0-beta3.
I'm attempting to spin-up a hub using the maxInstances parameter with the following command:
java -jar %~dp0DriverRepo\selenium-server-standalone-3.0.0-beta3.jar -role hub -port 5555 -maxInstances 9
This was working in 2.53.0, but in 3.0.0-beta3 I'm met with the following exception:
Exception in thread "main" com.beust.jcommander.ParameterException: Unknown option: -maxInstances
at com.beust.jcommander.JCommander.parseValues(JCommander.java:742)
at com.beust.jcommander.JCommander.parse(JCommander.java:282)
at com.beust.jcommander.JCommander.parse(JCommander.java:265)
at com.beust.jcommander.JCommander.<init>(JCommander.java:210)
at org.openqa.grid.selenium.GridLauncherV3$2.setConfiguration(GridLauncherV3.java:224)
at org.openqa.grid.selenium.GridLauncherV3.buildLauncher(GridLauncherV3.java:138)
at org.openqa.grid.selenium.GridLauncherV3.main(GridLauncherV3.java:67)
Apparently maxInstances is no longer a valid argument. I've searched for documentation regarding any changes that may have been made for use of the maxInstances parameter but I've had no luck. Has anyone else run into this issue, or is anyone aware of the proper way to spin-up a hub in 3.0.0-beta3 in a comparable way?
I don't remember ever using an argument called maxInstances. I think that earlier there was no validation for invalid command line arguments but with Selenium 3, they perhaps enabled it.
Here's an example of why I feel my theory is true
Selenium 2.53.1 output wherein I am providing an invalid argument named krishnan
selenium-server -role hub -krishnan 100
22:28:37.762 INFO - Launching Selenium Grid hub
2016-09-26 22:28:38.366:INFO::main: Logging initialized #758ms
22:28:38.378 INFO - Will listen on 4444
22:28:38.421 INFO - Will listen on 4444
2016-09-26 22:28:38.424:INFO:osjs.Server:main: jetty-9.2.z-SNAPSHOT
2016-09-26 22:28:38.452:INFO:osjsh.ContextHandler:main: Started o.s.j.s.ServletContextHandler#32eebfca{/,null,AVAILABLE}
2016-09-26 22:28:38.479:INFO:osjs.ServerConnector:main: Started ServerConnector#6ec8211c{HTTP/1.1}{0.0.0.0:4444}
And here's how Selenium 3 beta version behaves for the same command line.
java -jar selenium-server-standalone-3.0.0-beta2.jar -role hub -krishnan 100
Exception in thread "main" com.beust.jcommander.ParameterException: Unknown option: -krishnan
at com.beust.jcommander.JCommander.parseValues(JCommander.java:742)
at com.beust.jcommander.JCommander.parse(JCommander.java:282)
at com.beust.jcommander.JCommander.parse(JCommander.java:265)
at com.beust.jcommander.JCommander.<init>(JCommander.java:210)
at org.openqa.grid.selenium.GridLauncherV3$2.setConfiguration(GridLauncherV3.java:216)
at org.openqa.grid.selenium.GridLauncherV3.buildLauncher(GridLauncherV3.java:130)
at org.openqa.grid.selenium.GridLauncherV3.main(GridLauncherV3.java:67)
Selenium has never had any argument named maxInstances. It only had something called maxSession`.
The only usage for maxInstances has been within a node configuration file as shown here which is passed to a Selenium node via the -nodeConfig argument. This represents the number of concurrent browser instances per browser flavor that can be opened up in a node.

Selenium Exception with no stack trace (grunt / protractor / selenium)

I try to run grunt test, and Selenium exits without closing the browser. I am unable to see where the exception is coming from.
grunt test
Running "protractor_webdriver:start" (protractor_webdriver) task
Starting Selenium server
Started Selenium server: http://127.94.0.1:4444
Running "protractor:projecttest" (protractor) task
[10:16:33] I/hosted - Using the selenium server at http://localhost:4444/wd/hub
[10:16:33] I/launcher - Running 1 instances of WebDriver
Session created: count=1, browserName=chrome
......Exception thrown: Going to shut down the Selenium server
Shutting down Selenium server: http://127.94.0.1:4444
Shut down Selenium server: http://127.94.0.1:4444 (OKOK)
Fatal error: 10:16:45.529 WARN - Exception thrown
All of my tests are passing. I even added logs to prove the final test passes and exits without exception.
I tried to up my logging from "dots" to "progress" but it doesn't change anything. Any ideas?

Selenium Grid with safari browser

Plese Help me
How do I instantiate the Safari in selenium grid
capabilities = new DesiredCapabilities();
// Version browser
capabilities.setVersion(versaoBrowser);
capabilities.setBrowserName("safari");
capabilities.setJavascriptEnabled(true);
// Platform test runner
capabilities.setPlatform(platform);
On the server is weel
-browser "browserName=safari,version=5,platform=WINDOWS,javascriptEnable=true"
If the question is about using Safari the new way, with SafariDriver over Grid2, then this would be the typical method I believe (more or less):
import org.openqa.selenium.*;
import org.openqa.selenium.remote.*;
import java.net.*;
DesiredCapabilities c = new DesiredCapabilities();
c.setBrowserName("safari");
/* you can then set version & platform as well, but the minimum is just browser. Maybe for Grid2 you need the others, but for remote web driver only, you don't.
*/
WebDriver d = new RemoteWebDriver(new URL("http://hubIpOrHostname:hubPort/wd/hub"),c);
and that should work. On the server side, I believe you just instantiate normally for Grid2 per the wiki docs (last I check, could be diff now):
//start hub
java -jar selenium-server-standalone-2.21.0.jar -role hub -port theHubPort
//start the node
java -jar selenium-server-standalone-2.21.0.jar -role node -hub http:
//172.22.6.198:4446/wd/hub -port theNodePort
however, seems that the current Grid2 doesn't offer Safari support. When I looked up the console for the registered node in hub, it didn't show icon for Safari. Maybe I missed something. I'll try adding platform and version next time to see if that makes a diff but think not.
Here's a snippet of the error I get for Grid2 with SafariDriver:
May 11, 2012 6:01:11 PM org.openqa.selenium.remote.RemoteWebDriver execute
INFO: Executing: [null, newSession {"desiredCapabilities":"Capabilities [{browse
rName=safari}]"}]
// Error: // Uncaught Exception: Typed variable declaration : Object constructor
: at Line: 7 : in file: : new RemoteWebDriver ( new URL ( "http:
//172.22.6.198:4446/wd/hub" ) , c )
Target exception: org.openqa.selenium.WebDriverException: Error forwarding the n
ew session cannot find : {browserName=safari}
Command duration or timeout: 109 milliseconds
To note: with webdriver, same code can be used for (standalone) remote webdriver execution vs grid, difference is that for remote you use remote server ip and with grid2, you use hub ip. SafariDriver works over remote webdriver, but currently doesn't seem to work over Grid2 yet.
remote webdriver startup:
java -jar selenum-server-standalone-2.21.0.jar [-port somePort]
//default port of 4444
I believe what you are asking for is something like this?
selenium = new DefaultSelenium("localhost", 4444, *safari,"http://google.com.au");
selenium.start();
I generally use WebDriver, but my understanding is capabilities are options for when you create an instance of a browser, not to open the browser itself. Though I could be wrong as I am not experienced with Selenium Grid.
EDIT: This and this might help.

SeleniumRC FF3.5.x-3.6 lock file troubles

With Selenium RC 1.0.1, and FF3.5.x or 3.6 I keep seeing this error when trying to run any test,
Failed to start new browser session:
Unable to delete file
\parent.lock
when running the server with either,
java -jar selenium-server.jar -multiwindow
or
java -jar selenium-server.jar
Any one found a way to run a selenium RC test against those version of FF? Here's the full stack trace,
ERROR - Failed to start new browser session, shutdown browser and clear all session data
java.lang.RuntimeException: Firefox refused shutdown while preparing a profile
at org.openqa.selenium.server.browserlaunchers.FirefoxChromeLauncher.wai
tForFullProfileToBeCreated(FirefoxChromeLauncher.java:311)
at org.openqa.selenium.server.browserlaunchers.FirefoxChromeLauncher.pop
ulateCustomProfileDirectory(FirefoxChromeLauncher.java:106)
at org.openqa.selenium.server.browserlaunchers.FirefoxChromeLauncher.lau
nch(FirefoxChromeLauncher.java:83)
at org.openqa.selenium.server.browserlaunchers.FirefoxChromeLauncher.lau
nchRemoteSession(FirefoxChromeLauncher.java:350)
at org.openqa.selenium.server.browserlaunchers.FirefoxLauncher.launchRem
oteSession(FirefoxLauncher.java:98)
at org.openqa.selenium.server.BrowserSessionFactory.createNewRemoteSessi
on(BrowserSessionFactory.java:357)
at org.openqa.selenium.server.BrowserSessionFactory.getNewBrowserSession
(BrowserSessionFactory.java:122)
at org.openqa.selenium.server.BrowserSessionFactory.getNewBrowserSession
(BrowserSessionFactory.java:84)
at org.openqa.selenium.server.SeleniumDriverResourceHandler.getNewBrowse
rSession(SeleniumDriverResourceHandler.java:699)
at org.openqa.selenium.server.SeleniumDriverResourceHandler.doCommand(Se
leniumDriverResourceHandler.java:393)
at org.openqa.selenium.server.SeleniumDriverResourceHandler.handleComman
dRequest(SeleniumDriverResourceHandler.java:364)
at org.openqa.selenium.server.SeleniumDriverResourceHandler.handle(Selen
iumDriverResourceHandler.java:125)
at org.mortbay.http.HttpContext.handle(HttpContext.java:1530)
at org.mortbay.http.HttpContext.handle(HttpContext.java:1482)
at org.mortbay.http.HttpServer.service(HttpServer.java:909)
at org.mortbay.http.HttpConnection.service(HttpConnection.java:820)
at org.mortbay.http.HttpConnection.handleNext(HttpConnection.java:986)
at org.mortbay.http.HttpConnection.handle(HttpConnection.java:837)
at org.mortbay.http.SocketListener.handleConnection(SocketListener.java:
245)
at org.mortbay.util.ThreadedServer.handle(ThreadedServer.java:357)
at org.mortbay.util.ThreadPool$PoolThread.run(ThreadPool.java:534)
Caused by: org.openqa.selenium.server.browserlaunchers.FirefoxChromeLauncher$Fil
eLockRemainedException: Lock file still present! C:\DOCUME~1\ADMINI~1.SPS\LOCALS
~1\Temp\customProfileDirf09f31ccacf4468385010edaecd5925d\parent.lock
at org.openqa.selenium.server.browserlaunchers.FirefoxChromeLauncher.wai
tForFileLockToGoAway(FirefoxChromeLauncher.java:269)
at org.openqa.selenium.server.browserlaunchers.FirefoxChromeLauncher.wai
tForFullProfileToBeCreated(FirefoxChromeLauncher.java:309)
... 20 more
INFO - Got result: Failed to start new browser session: Unable to d
elete file C:\DOCUME~1\ADMINI~1.SPS\LOCALS~1\Temp\customProfileDirf09f31ccacf446
8385010edaecd5925d\parent.lock on session null
Restarting the browser, and clearing the cache didn't help. Using FF 3.0.x works just fine.
Seems seleniumRC 1.0.2 just came out today with claimed support for FF3.6 and such. Is working for me.
I was able to fix this issue by following these instructions:
http://jira.openqa.org/browse/SRC-507
This is for an older version of Selenium, but it works just the same. I am having to use 1.0.1 (for IE compatibility) and it has the MaxVersion of FF at 3.5. It was throwing the same error as above.
I changed the various files to '3.6' and it works now.
I just downloaded Selenium RC 1.0.3, and it did NOT fix the problem for me.