Giter VIP home page Giter VIP logo

java-maven-selenium's Introduction

Gauge example in Java

Build Status

This is an example project for doing web automation testing with Gauge. This project tests some of the functionalities of the active admin demo app. This app is hosted as a Java WAR (with embedded Jetty).

Running this example

The tests are run on Chrome by default.

Prerequisites

This example requires the following softwares to run.

  • Java 1.7 or above
    • Note that Gauge works with Java 1.6 and above. But this particular example uses Java 1.7
  • Gauge
  • Gauge Java plugin
    • can be installed using gauge install java
  • Chrome

Setting up the System Under Test (SUT)

java -jar activeadmin-demo.war

Setting up Maven

Run specs

If you already have Maven installed, you can execute specs as mvn test This runs Gauge specs with Maven.

This uses Chrome as default browser for specs execution. Make sure Chrome is installed in your machine and chromedriver is in PATH.

If you want to use Firefox/IE as browser, pass the corresponding argument to set browser environment as follows:

mvn gauge:execute -DspecsDir=specs -Denv="firefox"
or
mvn gauge:execute -DspecsDir=specs -Denv="ie"

Note:

  • Gauge can also be used with other build tools.
  • You can use Gauge even without a build script!

Topics covered in the example

Copyright

Copyright 2016, ThoughtWorks Inc.

java-maven-selenium's People

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar

java-maven-selenium's Issues

Failed to execute goal com.thoughtworks.gauge.maven:gauge-maven-plugin:1.3.0:execute

@Apoorva-GA

Observed below error while running in IntelliJ for java-maven-selenium framework. Please let me know solution for this issue

[ERROR] Failed to execute goal com.thoughtworks.gauge.maven:gauge-maven-plugin:1.3.0:execute (default) on project active_admin: Gauge Specs execution failed -> [Help 1]
[ERROR]
[ERROR] To see the full stack trace of the errors, re-run Maven with the -e switch.
[ERROR] Re-run Maven using the -X switch to enable full debug logging.
[ERROR]
[ERROR] For more information about the errors and possible solutions, please read the following articles:
[ERROR] [Help 1] http://cwiki.apache.org/confluence/display/MAVEN/MojoFailureException

Jenkins: gauge Java is not found

[JENKINS] Recording test results
Compatible version of plugin java not found. Installing plugin java...

The infomation when run gauge -v in jenkins' server:

Gauge version: 1.1.5
Commit Hash: f455126

Plugins
-------
html-report (4.0.12)
java (0.7.13)
xml-report (0.2.3)

Demo web app doesn't start and ends in an error

Steps

  1. Downloaded demo app war from here ==> https://github.com/getgauge-examples/activeadmin-demo/releases/download/untagged-f0befd5494efa4baabd2/activeadmin-demo.war

  2. Ran java -jar activeadmin-demo.war which resulted in below error

2021-11-26 07:51:28.159:INFO::main: Logging initialized @469ms
2021-11-26 07:51:28.159:INFO:oejr.Runner:main: Runner
2021-11-26 07:51:28.238:INFO:oejs.Server:main: jetty-9.2.9.v20150224
2021-11-26 07:51:35.629:WARN:oeja.AnnotationConfiguration:main: ServletContainerInitializers: detected. Class hierarchy: empty
2021-11-26 07:51:36.255:INFO:/:main: INFO: jruby 9.1.12.0 (2.3.3) 2017-06-15 33c6439 Eclipse OpenJ9 VM openj9-0.26.0 on 1.8.0_292-b10 +jit [mswin32-x86_64]
2021-11-26 07:51:36.257:INFO:/:main: INFO: using a shared (threadsafe!) runtime
2021-11-26 07:51:52.376:INFO:/:main: An exception happened during JRuby-Rack startup|load error: C:/Users/xxxx/AppData/Local/Temp/jetty-0.0.0.0-8080
-activeadmin-demo.war--any-7680445054590137724.dir/webapp/WEB-INF/config/environment -- java.lang.IllegalAccessException: Can not set static final boolean field
javax.crypto.JceSecurity.isRestricted to java.lang.Boolean|--- System|jruby 9.1.12.0 (2.3.3) 2017-06-15 33c6439 Eclipse OpenJ9 VM openj9-0.26.0 on 1.8.0_292-b10 +
jit [mswin32-x86_64]|Time: 2021-11-26 07:51:52 +0530|Server: jetty/9.2.9.v20150224|jruby.home: uri:classloader://META-INF/jruby.home||--- Context Init Parameters:
|jruby.max.runtimes = 1|jruby.min.runtimes = 1|public.root = /|rails.env = test||--- Backtrace|LoadError: load error: C:/Users/xxxx/AppData/Local/Te
mp/jetty-0.0.0.0-8080-activeadmin-demo.war-
-any-7680445054590137724.dir/webapp/WEB-INF/config/environment -- java.lang.IllegalAccessException: Can not set static
final boolean field javax.crypto.JceSecurity.isRestricted to java.lang.Boolean| require at org/jruby/RubyKernel.java:961| load_environment at uri:clas

Failed to execute goal com.thoughtworks.gauge.maven:gauge-maven-plugin:1.4.3:execute (default-cli) on project gurutest-gauge: Gauge Specs execution failed. null: GaugeExecutionFailedException -> [Help 1]

Gauge version:

Commit Hash: 28617ea
Plugins
html-report (4.0.10)
java (0.7.7)
json-report (0.3.3)
screenshot (0.0.1)

I ran this command
COUNTRY=SG ENVIRONMENT=staging RESPONSIVE_SCREEN_DEVICE=Desktop gauge_custom_build_path=./target/classes gauge_additional_libs=./target/dependency-jars runDocker=yes mvn -X -e gauge:execute -DspecsDir=specs/ -DinParallel=true -Dnodes=10 -Dtags="SERVICE=agent-contentvalidator&REGION=SG&TYPE=api&TEST=smoke,\!in-progress,\!EXCLUDE=staging" -Dflags=--env=staging

Successfully generated html-report to => /app/reports/html-report/2020-04-30 16.37.35/index.html
Successfully generated json-report to => /app/reports/json-report/2020-04-30 16.37.35
Specifications:	1 executed	1 passed	0 failed	0 skipped
Scenarios:	1 executed	1 passed	0 failed	0 skipped
Total time taken: 16.463s
[INFO] ------------------------------------------------------------------------
[INFO] BUILD FAILURE
[INFO] ------------------------------------------------------------------------
[INFO] Total time:  30.840 s
[INFO] Finished at: 2020-04-30T16:37:35Z
[INFO] ------------------------------------------------------------------------
[ERROR] Failed to execute goal com.thoughtworks.gauge.maven:gauge-maven-plugin:1.4.3:execute (default-cli) on project gurutest-gauge: Gauge Specs execution failed. null: GaugeExecutionFailedException -> [Help 1]
org.apache.maven.lifecycle.LifecycleExecutionException: Failed to execute goal com.thoughtworks.gauge.maven:gauge-maven-plugin:1.4.3:execute (default-cli) on project gurutest-gauge: Gauge Specs execution failed. null
    at org.apache.maven.lifecycle.internal.MojoExecutor.execute (MojoExecutor.java:215)
    at org.apache.maven.lifecycle.internal.MojoExecutor.execute (MojoExecutor.java:156)
    at org.apache.maven.lifecycle.internal.MojoExecutor.execute (MojoExecutor.java:148)
    at org.apache.maven.lifecycle.internal.LifecycleModuleBuilder.buildProject (LifecycleModuleBuilder.java:117)
    at org.apache.maven.lifecycle.internal.LifecycleModuleBuilder.buildProject (LifecycleModuleBuilder.java:81)
    at org.apache.maven.lifecycle.internal.builder.singlethreaded.SingleThreadedBuilder.build (SingleThreadedBuilder.java:56)
    at org.apache.maven.lifecycle.internal.LifecycleStarter.execute (LifecycleStarter.java:128)
    at org.apache.maven.DefaultMaven.doExecute (DefaultMaven.java:305)
    at org.apache.maven.DefaultMaven.doExecute (DefaultMaven.java:192)
    at org.apache.maven.DefaultMaven.execute (DefaultMaven.java:105)
    at org.apache.maven.cli.MavenCli.execute (MavenCli.java:956)
    at org.apache.maven.cli.MavenCli.doMain (MavenCli.java:288)
    at org.apache.maven.cli.MavenCli.main (MavenCli.java:192)
    at jdk.internal.reflect.NativeMethodAccessorImpl.invoke0 (Native Method)
    at jdk.internal.reflect.NativeMethodAccessorImpl.invoke (NativeMethodAccessorImpl.java:62)
    at jdk.internal.reflect.DelegatingMethodAccessorImpl.invoke (DelegatingMethodAccessorImpl.java:43)
    at java.lang.reflect.Method.invoke (Method.java:566)
    at org.codehaus.plexus.classworlds.launcher.Launcher.launchEnhanced (Launcher.java:289)
    at org.codehaus.plexus.classworlds.launcher.Launcher.launch (Launcher.java:229)
    at org.codehaus.plexus.classworlds.launcher.Launcher.mainWithExitCode (Launcher.java:415)
    at org.codehaus.plexus.classworlds.launcher.Launcher.main (Launcher.java:356)
Caused by: org.apache.maven.plugin.MojoFailureException: Gauge Specs execution failed. null
    at com.thoughtworks.gauge.maven.GaugeExecutionMojo.execute (GaugeExecutionMojo.java:125)
    at org.apache.maven.plugin.DefaultBuildPluginManager.executeMojo (DefaultBuildPluginManager.java:137)
    at org.apache.maven.lifecycle.internal.MojoExecutor.execute (MojoExecutor.java:210)
    at org.apache.maven.lifecycle.internal.MojoExecutor.execute (MojoExecutor.java:156)
    at org.apache.maven.lifecycle.internal.MojoExecutor.execute (MojoExecutor.java:148)
    at org.apache.maven.lifecycle.internal.LifecycleModuleBuilder.buildProject (LifecycleModuleBuilder.java:117)
    at org.apache.maven.lifecycle.internal.LifecycleModuleBuilder.buildProject (LifecycleModuleBuilder.java:81)
    at org.apache.maven.lifecycle.internal.builder.singlethreaded.SingleThreadedBuilder.build (SingleThreadedBuilder.java:56)
    at org.apache.maven.lifecycle.internal.LifecycleStarter.execute (LifecycleStarter.java:128)
    at org.apache.maven.DefaultMaven.doExecute (DefaultMaven.java:305)
    at org.apache.maven.DefaultMaven.doExecute (DefaultMaven.java:192)
    at org.apache.maven.DefaultMaven.execute (DefaultMaven.java:105)
    at org.apache.maven.cli.MavenCli.execute (MavenCli.java:956)
    at org.apache.maven.cli.MavenCli.doMain (MavenCli.java:288)
    at org.apache.maven.cli.MavenCli.main (MavenCli.java:192)
    at jdk.internal.reflect.NativeMethodAccessorImpl.invoke0 (Native Method)
    at jdk.internal.reflect.NativeMethodAccessorImpl.invoke (NativeMethodAccessorImpl.java:62)
    at jdk.internal.reflect.DelegatingMethodAccessorImpl.invoke (DelegatingMethodAccessorImpl.java:43)
    at java.lang.reflect.Method.invoke (Method.java:566)
    at org.codehaus.plexus.classworlds.launcher.Launcher.launchEnhanced (Launcher.java:289)
    at org.codehaus.plexus.classworlds.launcher.Launcher.launch (Launcher.java:229)
    at org.codehaus.plexus.classworlds.launcher.Launcher.mainWithExitCode (Launcher.java:415)
    at org.codehaus.plexus.classworlds.launcher.Launcher.main (Launcher.java:356)
Caused by: com.thoughtworks.gauge.maven.exception.GaugeExecutionFailedException
    at com.thoughtworks.gauge.maven.GaugeCommand.execute (GaugeCommand.java:34)
    at com.thoughtworks.gauge.maven.GaugeExecutionMojo.execute (GaugeExecutionMojo.java:123)
    at org.apache.maven.plugin.DefaultBuildPluginManager.executeMojo (DefaultBuildPluginManager.java:137)
    at org.apache.maven.lifecycle.internal.MojoExecutor.execute (MojoExecutor.java:210)
    at org.apache.maven.lifecycle.internal.MojoExecutor.execute (MojoExecutor.java:156)
    at org.apache.maven.lifecycle.internal.MojoExecutor.execute (MojoExecutor.java:148)
    at org.apache.maven.lifecycle.internal.LifecycleModuleBuilder.buildProject (LifecycleModuleBuilder.java:117)
    at org.apache.maven.lifecycle.internal.LifecycleModuleBuilder.buildProject (LifecycleModuleBuilder.java:81)
    at org.apache.maven.lifecycle.internal.builder.singlethreaded.SingleThreadedBuilder.build (SingleThreadedBuilder.java:56)
    at org.apache.maven.lifecycle.internal.LifecycleStarter.execute (LifecycleStarter.java:128)
    at org.apache.maven.DefaultMaven.doExecute (DefaultMaven.java:305)
    at org.apache.maven.DefaultMaven.doExecute (DefaultMaven.java:192)
    at org.apache.maven.DefaultMaven.execute (DefaultMaven.java:105)
    at org.apache.maven.cli.MavenCli.execute (MavenCli.java:956)
    at org.apache.maven.cli.MavenCli.doMain (MavenCli.java:288)
    at org.apache.maven.cli.MavenCli.main (MavenCli.java:192)
    at jdk.internal.reflect.NativeMethodAccessorImpl.invoke0 (Native Method)
    at jdk.internal.reflect.NativeMethodAccessorImpl.invoke (NativeMethodAccessorImpl.java:62)
    at jdk.internal.reflect.DelegatingMethodAccessorImpl.invoke (DelegatingMethodAccessorImpl.java:43)
    at java.lang.reflect.Method.invoke (Method.java:566)
    at org.codehaus.plexus.classworlds.launcher.Launcher.launchEnhanced (Launcher.java:289)
    at org.codehaus.plexus.classworlds.launcher.Launcher.launch (Launcher.java:229)
    at org.codehaus.plexus.classworlds.launcher.Launcher.mainWithExitCode (Launcher.java:415)
    at org.codehaus.plexus.classworlds.launcher.Launcher.main (Launcher.java:356)
[ERROR] 
[ERROR] 
[ERROR] For more information about the errors and possible solutions, please read the following articles:
[ERROR] [Help 1] http://cwiki.apache.org/confluence/display/MAVEN/MojoFailureException

The reports got generated but then i got this error.

DriverFactory Class should be updated

This Method Below Needs To Be Updated

public static WebDriver getDriver() {

        String browser = System.getenv("BROWSER");
        if (browser == null) {
            ChromeDriverManager.getInstance().setup();
            return new ChromeDriver();
        }
        switch (browser)
        {
            case "IE":
                InternetExplorerDriverManager.getInstance().setup();
                return new InternetExplorerDriver();
            case "FIREFOX":
                FirefoxDriverManager.getInstance().setup();
                return new FirefoxDriver();
            default:
                ChromeDriverManager.getInstance().setup();
                return new ChromeDriver();

        }
    }

All the DriverManager objects should be changed to WebDriverManager. Because I was getting the error of 'getInstance() method cannot be resolved' . I think it is because of old usage.

Use below method to getDriver

public static WebDriver getDriver() {
        String browser = System.getenv("BROWSER");
        if (browser == null) {
            WebDriverManager.chromedriver().setup();
            return new ChromeDriver();
        }
        switch (browser) {
            case "IE":
                WebDriverManager.iedriver().setup();
                return new InternetExplorerDriver();
            case "FIREFOX":
                WebDriverManager.firefoxdriver().setup();
                return new FirefoxDriver();
            default:
                WebDriverManager.chromedriver().setup();
                return new ChromeDriver();

        }
    }

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.