Skip to content

Commit

Permalink
Code refactored
Browse files Browse the repository at this point in the history
  • Loading branch information
osandadeshan committed Dec 30, 2023
1 parent 9f1f2f9 commit 9e2fa79
Show file tree
Hide file tree
Showing 45 changed files with 1,145 additions and 457 deletions.
Binary file not shown.
245 changes: 193 additions & 52 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,62 +1,32 @@
# Gauge Java Web UI Automation Demo

## Pre Requisites
## Pre-requisites
1. Java
2. Maven

## How to Install Gauge Core
**On Windows**
1. Install Chocolatey by executing the following command.

` @"%SystemRoot%\System32\WindowsPowerShell\v1.0\powershell.exe" -NoProfile -InputFormat None -ExecutionPolicy Bypass -Command "iex ((New-Object System.Net.WebClient).DownloadString(‘https://chocolatey.org/install.ps1'))" && SET "PATH=%PATH%;%ALLUSERSPROFILE%\chocolatey\bin"`
## How to install Gauge core
Follow the instructions mentioned in [Installing Gauge](https://docs.gauge.org/getting_started/installing-gauge?os=windows&language=java&ide=vscode) in the official [Gauge Documentation](https://docs.gauge.org/)

2. Install Gauge by executing the following command.
## How to install Gauge plugins
1. Open Command Prompt and execute following commands.

`choco install gauge`

**On MacOS**
1. Update Homebrew.
`gauge install java`

`brew update`

2. Install Gauge using Homebrew.
`gauge install html-report`

`brew install gauge`

**On Linux**
1. First, add Gauge’s GPG key with this command.
`gauge install json-report`

`sudo apt-key adv --keyserver hkp://pool.sks-keyservers.net --recv-keys 023EDB0B`

2. Then add Gauge to the repository list using this command.

`echo deb https://dl.bintray.com/gauge/gauge-deb nightly main | sudo tee -a /etc/apt/sources.list`

3. Finally, install Gauge using these commands.
`gauge install xml-report`

`sudo apt-get update`

`sudo apt-get install gauge`

## How to Install Gauge Plugins
1. Open Command Prompt and execute following commands.
`gauge install spectacle`

`gauge install java`

`gauge install html-report`

`gauge install json-report`

`gauge install xml-report`

`gauge install spectacle`

`gauge install flash`
`gauge install flash`

2. You can check the installation using the following command.

`gauge -v`
`gauge -v`

**Note:**
If the installation is success, it will output like this:

```markdown
Expand All @@ -71,7 +41,185 @@ If the installation is success, it will output like this:
xml-report (<version number>)
```

## Configurations for IE 11 on Windows
## Executing specifications

### General specs execution
- Run the below command to execute all specifications in `specs` directory

```
mvn gauge:execute -DspecsDir=specs
```

- Run the below command to execute a single specification

```
mvn gauge:execute -DspecsDir=specs/example.spec
```

- Run the below command to execute specifications in `specs` and `specDir` directories

```
mvn gauge:execute -DspecsDir="specs,specDir"
```

- Run the below command to execute the failed scenarios

```
mvn gauge:execute -Dflags="--failed"
```

- Run the below command to execute the repeat scenarios

```
mvn gauge:execute -Dflags="--repeat"
```

**Note:**
`mvn test-compile` should be used for the tool to get latest changes of user code.

### Execute specs In parallel

```
mvn gauge:execute -DspecsDir=specs -DinParallel=true
```

### Execute specs by tags expression

```
mvn gauge:execute -DspecsDir=specs -Dtags="!in-progress"
```

### Execute spec by scenario name

```
mvn gauge:execute -DspecsDir=specs -Dscenario="Scenario Name"
```

### Specifying execution environment

```
mvn gauge:execute -DspecsDir=specs -Denv="dev"
```

### Execute specs as a part of maven test phase

Run gauge specs in project as a part of maven test phase by adding the below execution to yor pom.xml

```
<build>
<plugins>
<plugin>
<groupId>com.thoughtworks.gauge.maven</groupId>
<artifactId>gauge-maven-plugin</artifactId>
<version>1.6.1</version>
<executions>
<execution>
<phase>test</phase>
<configuration>
<specsDir>specs</specsDir>
<environmentVariables>
<CUSTOM_ENV_VARIABLE>value</CUSTOM_ENV_VARIABLE>
</environmentVariables>
</configuration>
<goals>
<goal>execute</goal>
</goals>
</execution>
</executions>
</plugin>
</plugins>
</build>
```

`mvn test` command will also run gauge specs if the above mentioned execution is added to the projects pom.xml

### Validate specs in project

- Run the below command to execute all specifications in `specs` directory

```
mvn gauge:validate -DspecsDir=specs
```

- Run the below command to validate and ignore stub implementation suggestions

```
mvn gauge:validate -Dflags="--hide-suggestion"
```

### Execute specs as a part of maven test-compile phase

Validate gauge specs in project as a part of maven test-compile phase by adding the below execution to yor pom.xml

```
<build>
<plugins>
<plugin>
<groupId>com.thoughtworks.gauge.maven</groupId>
<artifactId>gauge-maven-plugin</artifactId>
<version>1.6.1</version>
<executions>
<execution>
<phase>test-compile</phase>
<configuration>
<specsDir>specs</specsDir>
<flags>
<flag>--hide-suggestion</flag>
</flags>
</configuration>
<goals>
<goal>validate</goal>
</goals>
</execution>
</executions>
</plugin>
</plugins>
</build>
```

### Running both validate and execute goals as part of maven

Add the following execution to pom.xml to run both goals:

```
<plugin>
<groupId>com.thoughtworks.gauge.maven</groupId>
<artifactId>gauge-maven-plugin</artifactId>
<version>1.6.1</version>
<executions>
<execution>
<id>validate</id>
<phase>test-compile</phase>
<goals>
<goal>validate</goal>
</goals>
</execution>
<execution>
<id>execute</id>
<phase>test</phase>
<goals><goal>execute</goal></goals>
<configuration>
<specsDir>specs</specsDir>
</configuration>
</execution>
</executions>
</plugin>
```

### All Properties

The following plugin properties can be additionally set:

| Property name | Usage | Description |
|---------------|-------------------------------------|---------------------------------------------------------------------------------------------------------------------------|
| specsDir | -DspecsDir=specs | Gauge specs directory path. Required for executing specs. Takes a comma separated list of specification files/directories |
| tags | -Dtags="tag1 & tag2" | Filter specs by specified tags expression |
| inParallel | -DinParallel=true | Execute specs in parallel |
| nodes | -Dnodes=3 | Number of parallel execution streams. Use with `parallel` |
| env | -Denv=qa | gauge env to run against |
| flags | -Dflags="--verbose,--simpleConsole" | Add additional gauge flags to execution |

## Internet Explorer 11 configurations for a Windows machine

1. Open **Registry Editor** (Windows Key + R → Type regedit → Press Enter).

Expand All @@ -97,11 +245,4 @@ If the installation is success, it will output like this:

10. Click on **OK** button.

|Browser |Version |
|-----------|---------------------------------------|
|Chrome |68.0.3440.106 (Official Build) (64-bit)|
|Firefox |61.0.2 (64-bit) |
|IE |11.228.17134.0 |
|Edge |42.17134.1.0 |

Tested on **Windows 10 Core i7 Machine**.
Tested with **Windows 10 Core i7 Machine**.
5 changes: 2 additions & 3 deletions concepts/login.cpt
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,7 @@ Date : 3/13/2020
Time : 2:27 PM
Description : This is a concept file

# Login using the email as <Email> and password as <Password>
# Login using the username as <Username> and password as <Password>

* On login page
* Login to the application using the email as <Email> and password as <Password>
* Page title is "My account - My Store"
* Login to the application using the username as <Username> and password as <Password>
11 changes: 0 additions & 11 deletions concepts/signout.cpt

This file was deleted.

4 changes: 2 additions & 2 deletions env/default/default.properties
Original file line number Diff line number Diff line change
Expand Up @@ -28,5 +28,5 @@ flash_server_port = 8000
# Browser
browser = chrome

# Base URL
application_endpoint = http://automationpractice.com/index.php?controller=authentication&back=my-account
# Application URL
application_endpoint = https://demoblaze.com/
4 changes: 2 additions & 2 deletions env/dev/dev.properties
Original file line number Diff line number Diff line change
Expand Up @@ -28,5 +28,5 @@ flash_server_port = 8000
# Browser
browser = headless-chrome

# Base URL
application_endpoint = http://automationpractice.com/index.php?controller=authentication&back=my-account
# Application URL
application_endpoint = https://demoblaze.com/
4 changes: 2 additions & 2 deletions env/prod/prod.properties
Original file line number Diff line number Diff line change
Expand Up @@ -28,5 +28,5 @@ flash_server_port = 8000
# Browser
browser = headless-chrome

# Base URL
application_endpoint = http://automationpractice.com/index.php?controller=authentication&back=my-account
# Application URL
application_endpoint = https://demoblaze.com/
4 changes: 2 additions & 2 deletions env/qa/qa.properties
Original file line number Diff line number Diff line change
Expand Up @@ -28,5 +28,5 @@ flash_server_port = 8000
# Browser
browser = headless-firefox

# Base URL
application_endpoint = http://automationpractice.com/index.php?controller=authentication&back=my-account
# Application URL
application_endpoint = https://demoblaze.com/
4 changes: 2 additions & 2 deletions env/uat/uat.properties
Original file line number Diff line number Diff line change
Expand Up @@ -28,5 +28,5 @@ flash_server_port = 8000
# Browser
browser = headless-chrome

# Base URL
application_endpoint = http://automationpractice.com/index.php?controller=authentication&back=my-account
# Application URL
application_endpoint = https://demoblaze.com/
Loading

0 comments on commit 9e2fa79

Please sign in to comment.