Skip to content

Commit 938f3c8

Browse files
authored
Merge pull request #3 from aquality-automation/feature/selenium-template
Add template for Selenium Java
2 parents 11f1018 + db53f9d commit 938f3c8

File tree

29 files changed

+662
-58
lines changed

29 files changed

+662
-58
lines changed

.gitignore

Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,29 @@
1+
# Compiled class file
2+
*.class
3+
4+
# Log file
5+
*.log
6+
7+
# BlueJ files
8+
*.ctxt
9+
10+
# Mobile Tools for Java (J2ME)
11+
.mtj.tmp/
12+
13+
# Package Files #
14+
*.jar
15+
*.war
16+
*.nar
17+
*.ear
18+
*.zip
19+
*.tar.gz
20+
*.rar
21+
22+
# virtual machine crash logs, see http://www.java.com/en/download/help/error_hotspot.xml
23+
hs_err_pid*
24+
25+
### IntelliJ IDEA ###
26+
.idea
27+
*.iws
28+
*.iml
29+
*.ipr

LICENSE

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -186,7 +186,7 @@
186186
same "printed page" as the copyright notice for easier
187187
identification within third-party archives.
188188

189-
Copyright [yyyy] [name of copyright owner]
189+
Copyright 2020 Aquality Automation
190190

191191
Licensed under the Apache License, Version 2.0 (the "License");
192192
you may not use this file except in compliance with the License.

README.md

Lines changed: 29 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -1,17 +1,34 @@
1-
# Templates
1+
# Aquality Selenium Template Project
22

3-
This repository contains templates for all *aquality automation* family libraries.
3+
Template for [aquality-selenium-java](https://github.com/aquality-automation/aquality-selenium-java) library.
44

5-
### Structure
5+
### Project structure
66

7-
- [**java/**](./java) (will be ready soon)
8-
- [**aquality-selenium-template**](./java/aquality-selenium-template)
9-
- [**aquality-appium-mobile-template**](./java/aquality-appium-mobile-template)
10-
- [**dotnet/**](./dotnet) (will be ready soon)
11-
- [**aquality-selenium-template**](./dotnet/aquality-selenium-template)
12-
- [**aquality-appium-mobile-template**](./dotnet/aquality-appium-mobile-template)
13-
- [**aquality-winappdriver-template**](./dotnet/aquality-winappdriver-template)
7+
- **src/test/java/aquality/selenium/template/**
8+
- **configuration/**: classes that used to fetch project config from [src/test/resources/environment](./src/test/resources/environment) folder
9+
- **models/**: classes that represent data models of the application under the test (POJO classes)
10+
- **forms/**: Page Objects
11+
- **glue/**
12+
- **hooks/**: Cucumber [hooks](https://cucumber.io/docs/cucumber/api/#hooks)
13+
- **stepdefinitions/**: step definition classes
14+
- **transformations/**: Cucumber [data transformations](https://cucumber.io/docs/cucumber/configuration/)
15+
- **features/**: Cucumber feature files with test scenarios
16+
- **runners/**: Cucumber test runners
17+
- **src/test/resources/**: resource files such as configurations and test data
1418

15-
### How to use
19+
### Configuration
1620

17-
Just download necessary template and go ahead!
21+
[settings.json](./src/test/resources/settings.json) file contains settings of Aquality Selenium library. Additional information you can find [here](https://github.com/aquality-automation/aquality-selenium-java/blob/master/Documentation.en.md).
22+
23+
[allure.properties](./src/test/resources/allure.properties) is a part of Allure Report configuration. See details [here](https://docs.qameta.io/allure/).
24+
25+
### Tests execution
26+
27+
Scenarios from feature files can be executed with TestNG plugin for IDE (Intellij Idea, Eclipse)
28+
or with Maven command ```mvn clean test``` where you can specify all necessary arguments.
29+
30+
### Reporting
31+
32+
Allure Framework is used as a reporting tool. Report data will be places in ```target/allure-results/``` folder (you can change it in [allure.properties](./src/test/resources/allure.properties) file).
33+
34+
Run maven command ```mvn allure:serve``` to build and open report in web browser.

azure-pipelines.yml

Lines changed: 38 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,38 @@
1+
# Maven
2+
3+
trigger:
4+
- master
5+
6+
pool:
7+
vmImage: 'windows-latest'
8+
9+
steps:
10+
- task: SonarCloudPrepare@1
11+
inputs:
12+
SonarCloud: 'SonarCloud'
13+
organization: 'aqualityautomation'
14+
scannerMode: 'CLI'
15+
configMode: 'file'
16+
extraProperties: |
17+
sonar.coverage.exclusions=**/**
18+
19+
- task: ScreenResolutionUtility@1
20+
inputs:
21+
displaySettings: 'optimal'
22+
23+
- task: Maven@3
24+
inputs:
25+
mavenPomFile: 'pom.xml'
26+
mavenOptions: '-Xmx3072m'
27+
javaHomeOption: 'JDKVersion'
28+
jdkVersionOption: '1.8'
29+
jdkArchitectureOption: 'x64'
30+
publishJUnitResults: true
31+
testResultsFiles: '**/surefire-reports/TEST-*.xml'
32+
goals: 'clean test -Dprofile=local'
33+
34+
- task: SonarCloudAnalyze@1
35+
36+
- task: SonarCloudPublish@1
37+
inputs:
38+
pollingTimeoutSec: '300'

dotnet/aquality-appium-mobile-template/README.md

Lines changed: 0 additions & 9 deletions
This file was deleted.

dotnet/aquality-selenium-template/README.md

Lines changed: 0 additions & 9 deletions
This file was deleted.

dotnet/aquality-winappdriver-template/README.md

Lines changed: 0 additions & 9 deletions
This file was deleted.

java/aquality-appium-mobile-template/README.md

Lines changed: 0 additions & 9 deletions
This file was deleted.

java/aquality-selenium-template/README.md

Lines changed: 0 additions & 9 deletions
This file was deleted.

pom.xml

Lines changed: 112 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,112 @@
1+
<?xml version="1.0" encoding="UTF-8"?>
2+
<project xmlns="http://maven.apache.org/POM/4.0.0"
3+
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
4+
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
5+
<modelVersion>4.0.0</modelVersion>
6+
7+
<groupId>com.github.aquality-automation</groupId>
8+
<artifactId>aquality-selenium-template</artifactId>
9+
<version>1.0-SNAPSHOT</version>
10+
11+
<licenses>
12+
<license>
13+
<name>The Apache Software License, Version 2.0</name>
14+
<url>http://www.apache.org/licenses/LICENSE-2.0.txt</url>
15+
<distribution>repo</distribution>
16+
</license>
17+
</licenses>
18+
19+
<properties>
20+
<aquality.selenium.version>LATEST</aquality.selenium.version>
21+
<cucumber.version>4.8.1</cucumber.version>
22+
<aspectj.version>1.8.10</aspectj.version>
23+
</properties>
24+
25+
<dependencies>
26+
<dependency>
27+
<groupId>com.github.aquality-automation</groupId>
28+
<artifactId>aquality-selenium</artifactId>
29+
<version>${aquality.selenium.version}</version>
30+
</dependency>
31+
32+
<dependency>
33+
<groupId>io.cucumber</groupId>
34+
<artifactId>cucumber-testng</artifactId>
35+
<version>${cucumber.version}</version>
36+
</dependency>
37+
38+
<dependency>
39+
<groupId>io.cucumber</groupId>
40+
<artifactId>cucumber-java</artifactId>
41+
<version>${cucumber.version}</version>
42+
</dependency>
43+
44+
<dependency>
45+
<groupId>ru.yandex.qatools.ashot</groupId>
46+
<artifactId>ashot</artifactId>
47+
<version>1.5.4</version>
48+
<exclusions>
49+
<exclusion>
50+
<groupId>org.seleniumhq.selenium</groupId>
51+
<artifactId>selenium-remote-driver</artifactId>
52+
</exclusion>
53+
</exclusions>
54+
</dependency>
55+
56+
<dependency>
57+
<groupId>org.projectlombok</groupId>
58+
<artifactId>lombok</artifactId>
59+
<version>1.18.6</version>
60+
<scope>provided</scope>
61+
</dependency>
62+
63+
<dependency>
64+
<groupId>io.qameta.allure</groupId>
65+
<artifactId>allure-cucumber4-jvm</artifactId>
66+
<version>2.13.2</version>
67+
</dependency>
68+
</dependencies>
69+
70+
<build>
71+
<plugins>
72+
<plugin>
73+
<groupId>org.apache.maven.plugins</groupId>
74+
<artifactId>maven-compiler-plugin</artifactId>
75+
<version>3.8.1</version>
76+
<configuration>
77+
<source>1.8</source>
78+
<target>1.8</target>
79+
</configuration>
80+
</plugin>
81+
82+
<plugin>
83+
<groupId>org.apache.maven.plugins</groupId>
84+
<artifactId>maven-surefire-plugin</artifactId>
85+
<version>2.22.2</version>
86+
87+
<configuration>
88+
<parallel>classes</parallel>
89+
<reuseForks>false</reuseForks>
90+
<testFailureIgnore>false</testFailureIgnore>
91+
<argLine>
92+
-javaagent:"${settings.localRepository}/org/aspectj/aspectjweaver/${aspectj.version}/aspectjweaver-${aspectj.version}.jar"
93+
</argLine>
94+
</configuration>
95+
96+
<dependencies>
97+
<dependency>
98+
<groupId>org.aspectj</groupId>
99+
<artifactId>aspectjweaver</artifactId>
100+
<version>${aspectj.version}</version>
101+
</dependency>
102+
</dependencies>
103+
</plugin>
104+
105+
<plugin>
106+
<groupId>io.qameta.allure</groupId>
107+
<artifactId>allure-maven</artifactId>
108+
<version>2.10.0</version>
109+
</plugin>
110+
</plugins>
111+
</build>
112+
</project>

sonar-project.properties

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
sonar.tests=src/test
2+
sonar.language=java
3+
sonar.java.binaries=.
4+
sonar.sourceEncoding=UTF-8
5+
sonar.projectKey=aquality-automation_aquality-selenium-java-template
Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
package aquality.selenium.template.configuration;
2+
3+
public class Configuration {
4+
5+
private static Environment currentEnvironment;
6+
7+
private Configuration() {
8+
}
9+
10+
public static Environment getCurrentEnvironment() {
11+
if (currentEnvironment == null) {
12+
final String envPropertyValue = System.getProperty("environment");
13+
currentEnvironment = envPropertyValue != null
14+
? Environment.valueOf(envPropertyValue.toUpperCase())
15+
: Environment.STAGE;
16+
}
17+
return currentEnvironment;
18+
}
19+
}
Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,27 @@
1+
package aquality.selenium.template.configuration;
2+
3+
import aquality.selenium.core.utilities.ISettingsFile;
4+
import aquality.selenium.core.utilities.JsonSettingsFile;
5+
6+
import java.nio.file.Path;
7+
import java.nio.file.Paths;
8+
9+
public enum Environment {
10+
PROD("prod"),
11+
STAGE("stage");
12+
13+
private ISettingsFile configFile;
14+
15+
Environment(String name) {
16+
this.configFile = getConfigFile(name);
17+
}
18+
19+
private ISettingsFile getConfigFile(final String envName) {
20+
Path resourcePath = Paths.get("environment", envName, "config.json");
21+
return new JsonSettingsFile(resourcePath.toString());
22+
}
23+
24+
public String getStartUrl() {
25+
return this.configFile.getValue("/startUrl").toString();
26+
}
27+
}
Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
Feature: Demo
2+
3+
@demo
4+
Scenario: Empty email validation is working on Contact Us page
5+
Given Main page is opened
6+
When I open Contact us page
7+
Then Contact us page is opened
8+
When I fill contact form using following data:
9+
| Name | Peter Parker |
10+
| Company | Aquality Automation |
11+
| Phone | +44 208 816 7320 |
12+
| Comment | I'd like to contact you! |
13+
And I accept Privacy and Cookies Policy
14+
And I click Send button
15+
Then Notification about empty fields is present
Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
package aquality.selenium.template.forms;
2+
3+
import aquality.selenium.elements.interfaces.IButton;
4+
import aquality.selenium.forms.Form;
5+
import org.openqa.selenium.By;
6+
7+
public class BaseAppForm extends Form {
8+
9+
private final IButton btnAcceptCookies = getElementFactory().getButton(By.id("cookie_action_close_header"), "Accept cookies");
10+
11+
protected BaseAppForm(final By locator, final String name) {
12+
super(locator, name);
13+
}
14+
15+
public void acceptCookies() {
16+
btnAcceptCookies.click();
17+
}
18+
}

0 commit comments

Comments
 (0)