Webdriver does not start in Jenkins - maven

I have the following setup:
Debian 7 (Headless with Xvfb)
Xvfb started via daemon at :0
Selenium 2.44 (declared in pom.xml)
Mozilla Firefox 35.0.1 (installed from firefox-mozilla-build)
Jenkins 1.598
I'm getting this exception when running the test:
java.lang.ExceptionInInitializerError: null
at org.openqa.selenium.firefox.internal.Executable.locateFirefoxBinaryFromSystemProperty(Executable.java:143)
at org.openqa.selenium.firefox.internal.Executable.<clinit>(Executable.java:43)
at org.openqa.selenium.firefox.FirefoxBinary.<init>(FirefoxBinary.java:59)
testResult(com.Test) Time elapsed: 0.049 sec <<< FAILURE!
java.lang.NoClassDefFoundError: Could not initialize class org.openqa.selenium.firefox.internal.Executable
at org.openqa.selenium.firefox.FirefoxBinary.<init>(FirefoxBinary.java:59)
I've tried so far;
Setting system property programatically:
System.setProperty("webdriver.firefox.bin", "/usr/bin/firefox");
Configuring it directly in the Webdriver:
File pathToBinary = new File("/usr/bin/firefox");
FirefoxBinary ffBinary = new FirefoxBinary(pathToBinary);
FirefoxProfile ffProfile = new FirefoxProfile();
webDriver = new FirefoxDriver(ffBinary,ffProfile);
Passing the parameter via Maven
-Dwebdriver.firefox.bin=/usr/bin/firefox
All of above has failed.
I've setup another Jenkins on my Ubuntu 14.04 and it works fine.
I've run from my IDE, it works fine.
I've run from commandline on my PC, it works fine.
Is there any other option I can try? Something I overlooked?
Thanks in advance!

Related

org.openqa.selenium.WebDriverException: Session [null] not available and is not among the last 1000 terminated sessions using SeleniumGrid in Docker

I am running selenium grid and has 2 nodes connected to it. But when I try to run a test script (.java) it gives the error:
Exception in thread "Thread-23" org.openqa.selenium.WebDriverException: Session [null] not available and is not among the last 1000 terminated sessions.
Active sessions are[ext. key 3e5f8fb2ae3b0c5cddc8817f80eb8fe1]
Command duration or timeout: 92 milliseconds
Build info: version: 'unknown', revision: 'unknown', time: 'unknown'
In the VNC client the chrome browser opens up but the url is not getting loaded and the error is thrown.
Note: The script is run from another docker container using maven.
When I run the script as a java application, it works fine, but in docker, I'm getting the error.**
This error message...
Exception in thread "Thread-23" org.openqa.selenium.WebDriverException: Session [null] not available and is not among the last 1000 terminated sessions.
Active sessions are[ext. key 3e5f8fb2ae3b0c5cddc8817f80eb8fe1]
Command duration or timeout: 92 milliseconds
Build info: version: 'unknown', revision: 'unknown', time: 'unknown'
...implies that the Selenium Grid Node was unable to communicate with the Selenium Grid Hub.
Deep Dive
This error is defined in ActiveTestSessions.java and is defined as:
public TestSession getExistingSession(ExternalSessionKey externalkey) {
TestSession sessionByExternalKey = findSessionByExternalKey(externalkey);
if (sessionByExternalKey == null) {
SessionTerminationReason sessionTerminationReason = reasons.get(externalkey);
String keyId = externalkey != null ? externalkey.getKey() : "(null externalkey)";
if (sessionTerminationReason != null) {
String msg = "Session [" + keyId + "] was terminated due to " + sessionTerminationReason;
log.fine(msg);
throw new GridException(msg);
} else {
String msg = "Session [" + keyId + "] not available and is not among the last 1000 terminated sessions.\n"
+ "Active sessions are" + this.unmodifiableSet();
log.fine(msg);
throw new GridException(msg);
}
}
return sessionByExternalKey;
}
As per the following discussions:
Session [....] not available and is not among the last 1000 terminated sessions
Selenium 3.9.0 & above gives error "Session [null] not available and is not among the last 1000 terminated sessions." on geckodriver
It seems this error stems out when:
Selenium Grid Hub, Selenium Grid Node and the Client Process are initiated/spawned from different versions of Selenium client.
Solution
Ensure that Selenium Grid Hub, Selenium Grid Node and the Client Process all of them uses the same version of Selenium client i.e. Selenium v3.141.59
Update 1
In normal circumstances you should have observed Selenium Webdriver + Java - Eclipse: java.lang.NoClassDefFoundError incase of presence of multiple versions of the same jar. A bit more details interms of your Test Architecture would have helped us to debug the issue in a better way. Possibly you need to clean up as follows:
mvn clean
mvn install
or mvn clean install
mvn test
Update 2
As the last resort you can delete the MAVEN_HOME i.e. ~/.m2 and re-initiate the build process.

IE capabilities with Jenkins

I have installed:
selenium grid 2.53.0 hub +node for IE;
Jenkins;
IE 11.
When I try to run a build for IE via batch command with variable BROWSER=ie I'm getting next error:
Error forwarding the new session cannot find : Capabilities [{browserName=internetexplorer, version=null}] (org.openqa.grid.common.exception.GridException) (Selenium::WebDriver::Error::UnknownError)
What can be wrong? Because when I run my tests not via grid everything is ok.
If I connect node for chrome and specify chrome everything is ok too.
Try this:
DesiredCapabilities cap = null;
WebDriver driver = null;
cap = DesiredCapabilities.internetExplorer();
cap.setBrowserName("internet explorer");
cap.setPlatform(Platform.WIN8); //specify the platform
driver = new RemoteWebDriver(new URL(nodeURL), cap);
I resolved this.
I specified incorrectly BROWSER value in Jenkins. Must be BROWSER="internet explorer"

Getting unable to discover open pages. Can't run my test suite from jenkins in chrome browser

I'm getting this stack trace.
Default Logging level is set to ERROR
Loping for strBrowserType chrome
Starting ChromeDriver (v2.9.248315) on port 42027
Tests run: 32, Failures: 1, Errors: 0, Skipped: 31, Time elapsed: 67.337 sec <<< FAILURE! - in TestSuite
setupSuite(com.ambab.carworkz.testcases.ServiceEstimatorTestTc) Time elapsed: 66.668 sec <<< FAILURE!
org.openqa.selenium.WebDriverException:
unknown error: unable to discover open pages
(Driver info: chromedriver=2.9.248315,platform=Windows NT 6.1 SP1 x86_64) (WARNING: The server did not provide any stacktrace information)
Command duration or timeout: 61.06 seconds
Build info: version: '2.53.0', revision: '35ae25b1534ae328c771e0856c93e187490ca824', time: '2016-03-15 10:43:46'
System info: host: 'ROBER-QA', ip: '192.168.0.70', os.name: 'Windows 7', os.arch: 'amd64', os.version: '6.1', java.version: '1.8.0_91'
Driver info: org.openqa.selenium.chrome.ChromeDriver
Results:
Failed tests:
ServiceEstimatorTestTc>Base.setupSuite:114 ยป WebDriver unknown error: unable t...
Tests run: 32, Failures: 1, Errors: 0, Skipped: 31
[ERROR] There are test failures.
I'm running test suite from jenkins in chrome browser that is the time when I'm facing this issue. If I directly run the suite from eclipse IDE then it runs fine. When I run the same test suite in firefox then also it runs fine.
I've installed the latest version of chrome, and chrome driver. Running jenkins job with maven.
Tried using no-sandbox as well as changes in chrome browser setting of automatic detect setting. Jenkins also I'm running the job on master and there is no slave. Tried every possible solution regarding this problem. If any more solution there then please let me know.
I've added this stuff and it solved it in my case. There also may be problem with user that is running jenkins (it should be set to Admin)
ChromeOptions options = new ChromeOptions();
options.AddUserProfilePreference("download.default_directory", DownloadsPath);
options.SetLoggingPreference(LogType.Browser, LogLevel.Severe);
options.AddArguments("ignore-certificate-errors");
options.AddArguments("--allow-running-insecure-content");
options.AddArguments("test-type");
options.AddArguments("start-maximized");
options.AddArguments("--disable-extensions");
options.AddArguments("no-sandbox");
var ChromeService = ChromeDriverService.CreateDefaultService();
ChromeService.HideCommandPromptWindow = true;
instance = new ChromeDriver(ChromeService, options, TimeSpan.FromSeconds(200));

Unable to resolve org.openqa.selenium.WebDriverException: Specified firefox binary location does not exist or is not a real file?

We are getting "org.openqa.selenium.WebDriverException: Specified firefox binary location does not exist or is not a real file: /usr/local/bin/firefox/firefox" exception when we ran the selenium web driver code via linux
Configuration:
aws-cli/1.7.38 Python/2.7.9 Linux/3.14.48-33.39.amzn1.x86_64
Amazon ElasticBeanStalk
Already installed firefox on /usr/local/bin/firefox/firefox
when i ran firefox --version the version clearly getting displayed in the console
Mozilla Firefox 38.1.0
File pathToBinary = new File("/usr/local/bin/firefox/firefox");
FirefoxBinary ffBinary = new FirefoxBinary(pathToBinary);
fBinary.setEnvironmentProperty("DISPLAY", ":1");
FirefoxDriver driver = new FirefoxDriver(ffBinary,pro);
xvfb is already started. (Xvfb :1 -screen 0 1280x768x24)
Please kindly help me on how to resolve the issue?
This problem occurred due to selenium library and firefox version conflict issue.

Webdriver/ Exception using grid and Safari: Error forwarding the new session

I use selenium-server-srandalone-2.35.0.jar.
In the server side, I run the next command: java -jar selenium-server-standalone-2.35.0.jar -role hub -port 4951
and with the next configuration:
DesiredCapabilities capability = DesiredCapabilities.safari();
capability.setBrowserName("safari");
capability.setPlatform(org.openqa.selenium.Platform.MAC);
WebDriver webdriver = new RemoteWebDriver(new URL("http://localhost:4951/wd/hub"), capability);
In the MAC computer, I run the next command: java -jar selenium-server-standalone-2.35.0.jar -role node -hub http://myIP:4951/grid/register
When I try to connect (in the new RemoteWebDriver...), It gives me the next excpetion:
org.openqa.selenium.WebDriverException: Error forwarding the new session cannot find : {platform=MAC, browserName=safari, version=}
Command duration or timeout: 720 milliseconds
I try to find the reason, but without success. Any help?
Please, try this:
java -jar selenium-server-standalone-2.35.0.jar -role wd -hub http://myIP:4951/grid/register -browser browserName=safari,platform=MAC
If it doesn't work, maybe you have to set a new capability (safari path):
capability.setCapability(SafariDriver.DATA_DIR_CAPABILITY,
"/Users/<your_user>/Library/Safari");
That works for me.

Resources