简体   繁体   中英

Selenium GUI tests keep failing when run from Jenkins (no such element)

Selenium GUI tests are not getting executed after the build. Everything is getting done in Jenkins using Maven.

TESTS

Forking command line: /bin/sh -c cd /var/lib/jenkins/jobs/dashboard/workspace/modules/ui/DashboardDemo/DashboardDemo_home && /usr/lib/jvm/java-7-oracle/jre/bin/java -jar /var/lib/jenkins/jobs/dashboard/workspace/modules/ui/DashboardDemo/DashboardDemo_home/target/surefire/surefirebooter4371762794186855568.jar /var/lib/jenkins/jobs/dashboard/workspace/modules/ui/DashboardDemo/DashboardDemo_home/target/surefire/surefire1890218106407957925tmp /var/lib/jenkins/jobs/dashboard/workspace/modules/ui/DashboardDemo/DashboardDemo_home/target/surefire/surefire_02979456989362369392tmp Running com.behavox.ui.demo.BudToneBehaviouralPatternPageTestUI /home/invictuslabs/Downloads/chromedriver SLF4J: Class path contains multiple SLF4J bindings. SLF4J: Found binding in [jar:file:/var/lib/jenkins/.m2/repository/ch/qos/logback/logback-classic/1.0.0/logback-classic-1.0.0.jar!/org/slf4j/impl/StaticLoggerBinder.class] SLF4J: Found binding in [jar:file:/var/lib/jenkins/.m2/repository/org/slf4j/slf4j-jdk14/1.6.4/slf4j-jdk14-1.6.4.jar!/org/slf4j/impl/StaticLoggerBinder.class] SLF4J: See http://www.slf4j.org/codes.html#multiple_bindings for an explanation. Starting ChromeDriver (v2.11.298611 (d1120fdf51badec2f7b63a96e19a58d4783de84d)) on port 26330 Only local connections are allowed. [0.111][WARNING]: PAC support disabled because there is no system implementation /home/invictuslabs/Downloads/chromedriver Starting ChromeDriver (v2.11.298611 (d1120fdf51badec2f7b63a96e19a58d4783de84d)) on port 22282 Only local connections are allowed. [0.501][WARNING]: PAC support disabled because there is no system implementation Tests run: 2, Failures: 0, Errors: 2, Skipped: 0, Time elapsed: 32.198 sec <<< FAILURE! Running com.behavox.ui.demo.BudToneTradingPageTestUI /home/invictuslabs/Downloads/chromedriver Starting ChromeDriver (v2.11.298611 (d1120fdf51badec2f7b63a96e19a58d4783de84d)) on port 17133 Only local connections are allowed. [0.502][WARNING]: PAC support disabled because there is no system implementation /home/invictuslabs/Downloads/chromedriver Starting ChromeDriver (v2.11.298611 (d1120fdf51badec2f7b63a96e19a58d4783de84d)) on port 28025 Only local connections are allowed. [0.498][WARNING]: PAC support disabled because there is no system implementation Tests run: 2, Failures: 0, Errors: 2, Skipped: 0, Time elapsed: 28.072 sec <<< FAILURE! Running com.behavox.ui.demo.FredricHooverBehaviouralPatternPageTestUI /home/invictuslabs/Downloads/chromedriver Starting ChromeDriver (v2.11.298611 (d1120fdf51badec2f7b63a96e19a58d4783de84d)) on port 15817 Only local connections are allowed. [0.502][WARNING]: PAC support disabled because there is no system implementation /home/invictuslabs/Downloads/chromedriver Starting ChromeDriver (v2.11.298611 (d1120fdf51badec2f7b63a96e19a58d4783de84d)) on port 31752 Only local connections are allowed. [0.502][WARNING]: PAC support disabled because there is no system implementation Tests run: 2, Failures: 0, Errors: 2, Skipped: 0, Time elapsed: 28.211 sec <<< FAILURE!

And so on (there are quite a lot of tests). Then:

Results :

Tests in error: navigationTest(com.behavox.ui.demo.BudToneBehaviouralPatternPageTestUI): no such element(..) generalTest(com.behavox.ui.demo.BudToneBehaviouralPatternPageTestUI): no such element(..) navigationTest(com.behavox.ui.demo.BudToneTradingPageTestUI): no such element(..) generalTest(com.behavox.ui.demo.BudToneTradingPageTestUI): no such element(..) navigationTest(com.behavox.ui.demo.FredricHooverBehaviouralPatternPageTestUI): no such element(..) generalTest(com.behavox.ui.demo.FredricHooverBehaviouralPatternPageTestUI): no such element(..) navigationTest(com.behavox.ui.demo.JohnSmithTradingPageTestUI): no such element(..) generalTest(com.behavox.ui.demo.JohnSmithTradingPageTestUI): no such element(..) navigationTest(com.behavox.ui.demo.JohnSmithBehaviouralPatternPageTestUI): no such element(..) generalTest(com.behavox.ui.demo.JohnSmithBehaviouralPatternPageTestUI): no such element(..)

And so on. At the very end of the log it gives me:

[ERROR] Failed to execute goal org.apache.maven.plugins:maven-surefire-plugin:2.12.2:test (ui-test) on project DashboardDemo_home: There are test failures. [ERROR] [ERROR] Please refer to /var/lib/jenkins/jobs/dashboard/workspace/modules/ui/DashboardDemo/DashboardDemo_home/target/surefire-reports for the individual test results. [ERROR] -> [Help 1] org.apache.maven.lifecycle.LifecycleExecutionException: Failed to execute goal org.apache.maven.plugins:maven-surefire-plugin:2.12.2:test (ui-test) on project DashboardDemo_home: There are test failures.

Please refer to /var/lib/jenkins/jobs/dashboard/workspace/modules/ui/DashboardDemo/DashboardDemo_home/target/surefire-reports for the individual test results. at org.apache.maven.lifecycle.internal.MojoExecutor.execute(MojoExecutor.java:213) at org.apache.maven.lifecycle.internal.MojoExecutor.execute(MojoExecutor.java:153) at org.apache.maven.lifecycle.internal.MojoExecutor.execute(MojoExecutor.java:145) at org.apache.maven.lifecycle.internal.LifecycleModuleBuilder.buildProject(LifecycleModuleBuilder.java:84) at org.apache.maven.lifecycle.internal.LifecycleModuleBuilder.buildProject(LifecycleModuleBuilder.java:59) at org.apache.maven.lifecycle.internal.LifecycleStarter.singleThreadedBuild(LifecycleStarter.java:183) at org.apache.maven.lifecycle.internal.LifecycleStarter.execute(LifecycleStarter.java:161) at org.apache.maven.DefaultMaven.doExecute(DefaultMaven.java:320) at org.apache.maven.DefaultMaven.execute(DefaultMaven.java:156) at org.apache.maven.cli.MavenCli.execute(MavenCli.java:537) at org.apache.maven.cli.MavenCli.doMain(MavenCli.java:196) at org.apache.maven.cli.MavenCli.main(MavenCli.java:141) at sun.reflect.NativeMethodAccessorIm pl.invoke0(Native Method) at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:57) at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43) at java.lang.reflect.Method.invoke(Method.java:606) at org.codehaus.plexus.classworlds.launcher.Launcher.launchEnhanced(Launcher.java:290) at org.codehaus.plexus.classworlds.launcher.Launcher.launch(Launcher.java:230) at org.codehaus.plexus.classworlds.launcher.Launcher.mainWithExitCode(Launcher.java:409) at org.codehaus.plexus.classworlds.launcher.Launcher.main(Launcher.java:352) Caused by: org.apache.maven.plugin.MojoFailureException: There are test failures.

I run the same tests on the local machine from IDEA and it works perfectly well.

Another thing is that (I am not sure whether it is supposed to be like this) when I run my tests from Jenkins, Chrome is not getting opened for some reason. However, I cannot see the reason why and errors do not seem very informative to me. Any ideas? Thanks!

You need to execute GUI tests via Jenkins in headless mode. Setup in Linux below: http://scraping.pro/use-headless-firefox-scraping-linux/

OR you may have to use a head less browsers

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM