1)I have created a job in Jenkins to run selenium tests cases which consists of 5 feature files
2)I am using "Execute Shell" of Jenkins to run the test cases
where I have fired the command by going to that particular folder and running command gradle test
eg. >cd ABC
>gradle test
when I run this job by using "build Now" the test cases fails showing error
1)java.lang.IllegalStateException: Failed to load ApplicationContext
2)Caused by: org.springframework.beans.BeanInstantiationException: Failed to instantiate [org.openqa.selenium.WebDriver]: Factory method 'getWebDriver' threw exception; nested exception is java.lang.NoClassDefFoundError: Could not initialize class com.cosmicapp.webbrowser.FirefoxWebDriver
3)caused by java.lang.NoClassDefFoundError: Could not initialize class com.cosmicapp.webbrowser.FirefoxWebDriver
And when I run the above test cases on my machine it runs fine.
It seems there is a problem in the Jenkins project workspace or Jenkins is not able to invoke firefox or chrome browser.
Related
I'm trying to run a basic TestNG class, but I'm getting this exception Exception in thread "main" com.beust.jcommander.ParameterException: Was passed main parameter '-d' but no main parameter was defined in your arg class
If I give main() and try with run as a java application, it's launching the browser fine. But when I run as TestNG, it's throwing Exception. I tried adding jcommander.jar manually and even tried with update maven project.
#Test
public void checking()
{
System.setProperty("webdriver.chrome.driver", "./driver/chromedriver");
ChromeDriver driver = new ChromeDriver();
driver.manage().window().maximize();
driver.get("https://www.google.com");
}
}
I expect the browser has to launch and load google.com, but I'm getting Exception in thread "main" com.beust.jcommander.ParameterException: Was passed main parameter '-d' but no main parameter was defined in your arg class
at com.beust.jcommander.JCommander.initMainParameterValue(JCommander.java:936)
at com.beust.jcommander.JCommander.parseValues(JCommander.java:752)
at com.beust.jcommander.JCommander.parse(JCommander.java:340)
at com.beust.jcommander.JCommander.parse(JCommander.java:319)
at com.beust.jcommander.JCommander.<init>(JCommander.java:253)
at org.testng.remote.RemoteTestNG.main(RemoteTestNG.java:44)
check whether testng installed successfully and jars have been added properly in maven
The scenario is:
I have serenity tests that i launch with chromedriver that work
When i launch the tests without headless option the tests are "passed"
while with the headless mode the tests are failed with error:
net.serenitybdd.core.exceptions.SerenityManagedException: The following error occurred: Timed out after 5 seconds. Element not available
here the line command that launch the test : mvn clean verify -Dwebdriver.driver=chrome
And the serenity.properties:
webdriver.chrome.driver = chromedriver
webdriver.base.url= ********
webdriver.timeouts.implicitlywait=5000
chrome.switches=--headless;
serenity.browser.maximized = true
The solution is to add in chrome.switches --window-size=1920,1080;
chrome.switches=--window-size=1920,1080;--headless;
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?
I am automating my protractor integration tests using Jenkins. When some of the tests fails Jenkins weeps saying that the result was successful. This is my output:
24 specs, 1 failure
Finished in 64.079 seconds
Shutting down selenium standalone server.
[launcher] 0 instance(s) of WebDriver still running
[launcher] chrome #1 failed 1 test(s)
[launcher] overall: 1 failed spec(s)
[launcher] Process exited with error code 1
Test failed but keep the grunt process alive.
Done, without errors.[39m
Terminating xvnc.
$ vncserver -kill :28
Killing Xtightvnc process ID 24369
Finished: SUCCESS
I don't know if my problem is selenium or grunt related.
Does any one know what can be the problem? Thanks in advance!
Looks like this Jenkins job is not set up properly, I suggest you review your Job Configuration.
After some research I found out the problem.
I am using "grunt-protractor-runner" library. It has an option call "keepAlive" and it was set to true. This caused the process to continue even is something was wrong and not passing the error code to grunt.
After set it up to false everything behave as expected.
I launched the tests IDE (selenium) from jenkins and I uploaded the XUNIT plugin for having a nice report of test but at the end I obtained this message of ERROR :
Tests failed, see result file for details:
D:\FTP\stm_atos_automatisation\rapports\ff39\rapport_ff39.html ERROR: Build step failed with exception java.lang.NullPointerException: The types section is required.
at org.jenkinsci.plugins.xunit.XUnitProcessor.<init>(XUnitProcessor.java:65)
at org.jenkinsci.plugins.xunit.XUnitPublisher.perform(XUnitPublisher.java:111)
at hudson.tasks.BuildStepMonitor$1.perform(BuildStepMonitor.java:20)
at hudson.model.AbstractBuild$AbstractBuildExecution.perform(AbstractBuild.java:779)
at hudson.model.AbstractBuild$AbstractBuildExecution.performAllBuildSteps(AbstractBuild.java:726)
at hudson.model.Build$BuildExecution.post2(Build.java:185)
at hudson.model.AbstractBuild$AbstractBuildExecution.post(AbstractBuild.java:671)
at hudson.model.Run.execute(Run.java:1766)
at hudson.model.FreeStyleBuild.run(FreeStyleBuild.java:43)
at hudson.model.ResourceController.execute(ResourceController.java:98)
at hudson.model.Executor.run(Executor.java:381) Build step 'Publish xUnit test result report' marked build as failure Finished: FAILURE
Is there any way to solve this problem?
I was getting this error too when I first enabled the XUnit plugin.
I hadn't realized (or had forgotten) that I needed to add a report type to the XUnit build step configuration. To do so, click Add and then select the type of report you want parsed (for me it was PHPUnit-3.x). See this screenshot. You'll also have to specify the path to the XML report files that you want parsed. (I'm using Codeception, so it was tests/_log/*.xml.)