Skip to content

Commit 39f9a92

Browse files
#3 Sauce labs configuration (#66)
* Some minor documentation updates * Initial commit of the changes needed to integrsate ssaucelabs to the framework * Fixing some codacy complaints * Removing Codacy * Configuring SonarCloud * Fixing travis * Addressing SonarCloud issues and switching up project badges * Fixing some unit test issued * Moving ITs to Ts * Adding some more tests for the webdriver utils * Adding more tests * Removing some unneeded comments * Adding saucelabs username to build badge
1 parent 3ab6a09 commit 39f9a92

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

54 files changed

+1407
-548
lines changed

.codacy.yml

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

.travis.yml

Lines changed: 4 additions & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,8 @@ dist: trusty
22
language: java
33
jdk:
44
- openjdk13
5+
git:
6+
depth: false
57
cache:
68
directories:
79
- "$HOME/.m2"
@@ -10,8 +12,6 @@ before_script:
1012
- sh -e /etc/init.d/xvfb start
1113
- sleep 3
1214
before_install:
13-
- openssl aes-256-cbc -K $encrypted_25a884814f46_key -iv $encrypted_25a884814f46_iv
14-
-in deployment/signingkey.asc.enc -out deployment/signingkey.asc -d
1515
- cp .travis.settings.xml $HOME/.m2/settings.xml
1616
- "/sbin/start-stop-daemon --start --quiet --pidfile /tmp/custom_xvfb_99.pid --make-pidfile
1717
--background --exec /usr/bin/Xvfb -- :99 -ac -screen 0 1280x1024x16"
@@ -21,32 +21,10 @@ before_install:
2121
addons:
2222
firefox: latest
2323
install:
24-
- mvn clean install -Dmaven.javadoc.skip=true -B -V
24+
- mvn verify org.sonarsource.scanner.maven:sonar-maven-plugin:sonar
2525
- bash scripts/get-bank-holiday-data-source-and-store-in-resources.sh
26-
after_success:
27-
- gpg2 --keyring=$TRAVIS_BUILD_DIR/pubring.gpg --no-default-keyring --import deployment/signingkey.asc
28-
- gpg2 --allow-secret-key-import --keyring=$TRAVIS_BUILD_DIR/secring.gpg --no-default-keyring
29-
--import deployment/signingkey.asc
30-
- mvn clean deploy -Dgpg.executable=gpg2 -Dgpg.keyname=5F84CD1775351968CABF0B0D779D2423E1D24D89
31-
-Dgpg.passphrase=$GPG_PASSPHRASE -Dgpg.publicKeyring=$TRAVIS_BUILD_DIR/pubring.gpg -Dgpg.secretKeyring=$TRAVIS_BUILD_DIR/secring.gpg
3226
deploy:
33-
- provider: script
34-
script: mvn test com.gavinmogan:codacy-maven-plugin:coverage -DcoverageReportFile=target/site/jacoco/jacoco.xml
35-
-DprojectToken=$CODACY_PROJECT_TOKEN -DapiToken=$CODACY_API_TOKEN
36-
on:
37-
branch: master
3827
- provider: script
3928
script: bash scripts/publish-javadocs-to-github-pages.sh
4029
on:
41-
tags: true
42-
- provider: script
43-
script:
44-
- mvn release:prepare
45-
- mvn release:perform
46-
on:
47-
tags: true
48-
env:
49-
global:
50-
- secure: cM73yz9Rj/wlGB+iIKnerkMhOH6dwMw97e0eNN8qIaA3x6Wp9JGwLOkctQTkOB3HgTsaO6I6/eIWylb8bzdQhu08zZvEmAGr8MXSRNtQm5l2zdx4uovwp8VAr2DBFmk1uyOXErwqsTo7ofSkjDcjNN57XR28frFYAuYAqa0+M9hMC4PWkawI22k9LgLA8LtR0Yzkto8eH1bw74YPMXhjjBZ6b/BTUqAOkwWbGujUmLtT7VeEMxKGJwgyoCw2+UKRtdAU+/E0LCAU2DuxYTtn00Om7GDV5eXZu58s+mRLMRG2038U/Bam4dTy6ZNrKjHlR3l3yyhSKKarG6st7cHvqYI2eaHi6L205o9RI4jqihIfPhxX2AtYGimSrQzHEvrc2hXqM4oqqT8xM6BCRIGfBmImUikBh3d+MubFXlne/mEPyq+csDer3Waz0sD2OrxtPjIKUGAltH61g/Wy54L4IVd5KzhX65lddYRMTyALyiTzWmYDmfD/IvhPOurjz4GU4FiNbBxiihKgc4FPFXWPRJVMu5Hb20b4g4RungBFtyBxw24VzwOaMOz7d9K8bR2NMydT/QaaLG3OQvTkO/2xQN00ddy1KJ7O7S1MGRJFq5ZEUjvUDAeRAANY86GVMk4lKh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4oJ8z2wxcEXe5YIO9G8S3sNaLIAQNLTwjfGFBP9YVWhZng1OBdLvh8+/r3kuPlilEu7H4M8iQ5zl9iV4SiguLOzcbV0hDm6F2UnUhvUwy8PJoDKVXJjW7PbYMBwGKnOu7QFG7LrLVCM7zORHfg+iu317yFdZLF+Jn+mBu5WGY+Jgr3rJnkgC7s5mQ+KKrWeFc/fZirykC8RbCkuss5KeQvkIiLtExvHP/1jPld/mhM2ItfCR6REVwHCN7zBYK56S8fa+oxT4ozc2p6Ked/F+QrrS0LekWcS0QnWYD5/Bp0iJVjL1HMv0vOKJimbmSf2athuFGA1gkTpBPKG7opSZf58=
30+
tags: true

README.md

Lines changed: 8 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,21 +1,24 @@
11
# selenium-pom-framework
22
[![Build Status](https://travis-ci.com/digital-delivery-academy/selenium-pom-framework.svg?branch=master)](https://travis-ci.com/digital-delivery-academy/selenium-pom-framework)
3-
[![Codacy Badge](https://api.codacy.com/project/badge/Grade/98cb1cb4ac7a4061b8677ffb246cc963)](https://www.codacy.com/gh/digital-delivery-academy/selenium-pom-framework?utm_source=github.com&utm_medium=referral&utm_content=digital-delivery-academy/selenium-pom-framework&utm_campaign=Badge_Grade)
4-
[![Codacy Badge](https://api.codacy.com/project/badge/Coverage/98cb1cb4ac7a4061b8677ffb246cc963)](https://www.codacy.com/gh/digital-delivery-academy/selenium-pom-framework?utm_source=github.com&utm_medium=referral&utm_content=digital-delivery-academy/selenium-pom-framework&utm_campaign=Badge_Coverage)
5-
[![Sauce Test Status](https://saucelabs.com/buildstatus/YOUR_SAUCE_USERNAME)](https://app.saucelabs.com/u/stevewalton)
63
[![GitHub Issues badge](https://img.shields.io/github/issues-raw/digital-delivery-academy/selenium-pom-framework?color=green)](https://github.com/digital-delivery-academy/selenium-pom-framework/issues)
74
[![All Contributors](https://img.shields.io/badge/all_contributors-3-orange.svg?style=flat-square)](#contributors)
5+
6+
[![Coverage](https://sonarcloud.io/api/project_badges/measure?project=digital-delivery-academy_selenium-pom-example&metric=coverage)](https://sonarcloud.io/dashboard?id=digital-delivery-academy_selenium-pom-example)
7+
[![Reliability Rating](https://sonarcloud.io/api/project_badges/measure?project=digital-delivery-academy_selenium-pom-example&metric=reliability_rating)](https://sonarcloud.io/dashboard?id=digital-delivery-academy_selenium-pom-example)
8+
[![Security Rating](https://sonarcloud.io/api/project_badges/measure?project=digital-delivery-academy_selenium-pom-example&metric=security_rating)](https://sonarcloud.io/dashboard?id=digital-delivery-academy_selenium-pom-example)
9+
[![Sauce Test Status](https://saucelabs.com/buildstatus/stevewalton)](https://app.saucelabs.com/u/stevewalton)
10+
811
[![Latest version badge](https://img.shields.io/github/v/release/digital-delivery-academy/selenium-pom-framework)](https://github.com/digital-delivery-academy/selenium-pom-framework/releases)
912
<!-- ALL-CONTRIBUTORS-BADGE:START - Do not remove or modify this section -->
1013
<!-- ALL-CONTRIBUTORS-BADGE:END -->
1114

1215
**We've released version 1.0.0! And we've moved to Maven Central hosting and added instrumentation**
1316

14-
This toolkit is really a culmination of 10 years of working with teams building automated UI checks with Selenium. We've found time and again that we refactor or rewrite "frameworks" that wrap the entirity of the Selenium API (to little benefit). On top of this, we see so much brittle code that we wanted to put something out there that people could use and benefit from our experience. As a result, this toolkit provides an simple, lightweight (and well structured) way to launch, control and configure checks for Selenium/WebDriver in Java. It's a curation of all of the little libraries and fixes we've used over the years. So if you're at the start of your automation journey or you're just bored of writing the same "framework" over and over again, you're in the right place.
17+
This toolkit is really a culmination of 10 years of working with teams building automated UI checks with Selenium. We've found time and again that we refactor or rewrite "frameworks" that wrap the entirety of the Selenium API (to little benefit). On top of this, we see so much brittle code that we wanted to put something out there that people could use and benefit from our experience. As a result, this toolkit provides an simple, lightweight (and well structured) way to launch, control and configure checks for Selenium/WebDriver in Java. It's a curation of all of the little libraries and fixes we've used over the years. So if you're at the start of your automation journey or you're just bored of writing the same "framework" over and over again, you're in the right place.
1518

1619
You'll find no junk (hopefully) here, but it's a fairly opinionated approach:
1720
- There's no mass "wrapper" on Selenium - that's dumb
18-
- We suggest using the Page Object Model, it's generally a good idea and we provide a starting point for this
21+
- We suggest using the Page Object Model, it's generally a good idea, and we provide a starting point for this
1922
- We resolve Driver binaries from WebDriverManager (https://github.com/bonigarcia/webdrivermanager)
2023
- We provide random test data generators from Mockneat (https://github.com/nomemory/mockneat) and UK Gov (https://github.com/dwp/nino-format-validation) as well as some of our own (for dates and stuff)
2124
- There's an externalised (and overridable) configuration system, based on JSON

pom.xml

Lines changed: 9 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -104,7 +104,11 @@
104104
<javadoc.maven.plugin.version>3.1.1</javadoc.maven.plugin.version>
105105
<joda.time.version>2.7</joda.time.version>
106106
<restassured.version>4.2.0</restassured.version>
107+
<saucelabs.bindings>1.0.0</saucelabs.bindings>
107108
<dropwizard.metrics.version>4.1.2</dropwizard.metrics.version>
109+
<sonar.projectKey>digital-delivery-academy_selenium-pom-example</sonar.projectKey>
110+
<sonar.organization>digital-delivery-academy</sonar.organization>
111+
<sonar.host.url>https://sonarcloud.io</sonar.host.url>
108112
</properties>
109113

110114
<dependencies>
@@ -193,6 +197,11 @@
193197
<artifactId>hamcrest-library</artifactId>
194198
<version>${hamcrest.version}</version>
195199
</dependency>
200+
<dependency>
201+
<groupId>com.saucelabs</groupId>
202+
<artifactId>sauce_bindings</artifactId>
203+
<version>${saucelabs.bindings}</version>
204+
</dependency>
196205
<dependency>
197206
<groupId>org.eclipse.jetty</groupId>
198207
<artifactId>jetty-server</artifactId>
@@ -214,20 +223,6 @@
214223
<skip>false</skip>
215224
</configuration>
216225
</plugin>
217-
<plugin>
218-
<groupId>org.apache.maven.plugins</groupId>
219-
<artifactId>maven-failsafe-plugin</artifactId>
220-
<version>${maven.failsafe.version}</version>
221-
<executions>
222-
<execution>
223-
<phase>test</phase>
224-
<goals>
225-
<goal>integration-test</goal>
226-
<goal>verify</goal>
227-
</goals>
228-
</execution>
229-
</executions>
230-
</plugin>
231226
<plugin>
232227
<groupId>org.codehaus.mojo</groupId>
233228
<artifactId>versions-maven-plugin</artifactId>

saucelabs-fs.json

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
{
2+
"acceptInsecureCerts": true,
3+
"strictFileInteractability": true,
4+
"capturePerformance": true,
5+
"extendedDebugging": false,
6+
"recordLogs": true,
7+
"recordScreenshots": true,
8+
"recordVideo": true,
9+
"saucePlatform": "WINDOWS_10",
10+
"browserName": "CHROME",
11+
"browserVersion": "LATEST",
12+
"pageLoadStrategy": "NORMAL",
13+
"seleniumVersion": "3.7.1",
14+
"sauceLabsRemoteGridUrl": "https://ondemand.saucelabs.com/wd/hub",
15+
"unhandledPromptBehaviour": "DISMISS"
16+
}
Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,4 @@
11
#!/usr/bin/env sh
22

33
curl https://www.gov.uk/bank-holidays.json --output src/main/resources/bank-holidays.json
4-
echo "STEVE STEVE STEVE"
54
ls src/main/resources
Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
package uk.co.evoco.exceptions;
2+
3+
public class SauceLabsCredentialsException extends Exception {
4+
5+
public SauceLabsCredentialsException() {
6+
super("Tried to get credentials from system variable SAUCE_USERNAME and SAUCE_ACCESS_KEY but could not find them");
7+
throw new RuntimeException("Can't execute against SauceLabs without valid credentials being provided, see stack trace from SauceLabsCredentialsException");
8+
}
9+
}

src/main/java/uk/co/evoco/pageobjects/BasePageObject.java

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -22,11 +22,9 @@ public abstract class BasePageObject {
2222
* instance available to child classes.
2323
* @param webDriver active WebDriver instance
2424
*/
25-
public BasePageObject(WebDriver webDriver) {
25+
protected BasePageObject(WebDriver webDriver) {
2626
PageFactory.initElements(webDriver, this);
2727
this.webDriver = webDriver;
2828
this.wait = new WebDriverWait(this.webDriver, TestConfigHelper.get().getWebDriverWaitTimeout());
2929
}
30-
31-
// TODO: fill() submit()
3230
}

src/main/java/uk/co/evoco/testdata/BankHoliday.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -32,6 +32,6 @@ public LocalDate getLocalDate() {
3232

3333
@JsonProperty("date")
3434
public void setLocalDate(String localDate) {
35-
this.localDate = new LocalDate().parse(localDate);
35+
this.localDate = LocalDate.parse(localDate);
3636
}
3737
}
Lines changed: 57 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,57 @@
1+
package uk.co.evoco.tests;
2+
3+
import org.junit.jupiter.api.AfterEach;
4+
import org.junit.jupiter.api.BeforeAll;
5+
import org.junit.jupiter.api.BeforeEach;
6+
import org.openqa.selenium.support.events.EventFiringWebDriver;
7+
import uk.co.evoco.exceptions.SauceLabsCredentialsException;
8+
import uk.co.evoco.webdriver.WebDriverListener;
9+
import uk.co.evoco.webdriver.configuration.TestConfigHelper;
10+
import uk.co.evoco.webdriver.configuration.driver.ConfiguredDriver;
11+
import uk.co.evoco.webdriver.configuration.driver.ConfiguredSauceLabsGridDriver;
12+
13+
import java.io.IOException;
14+
15+
/**
16+
* BaseAbstractTest to handle things that testers shouldn't need to worry about (like starting up a WebDriver instance
17+
* and getting everything in the right space for consumers to run tests that are correctly configured etc).
18+
*/
19+
public abstract class BaseAbstractSauceLabsTest {
20+
21+
protected EventFiringWebDriver webDriver;
22+
23+
/**
24+
* This will run before every test class.
25+
* This method gets the configuration and constructs the WebDriver instance, the screenshot
26+
* directory and the makes these items accessible.
27+
*/
28+
@BeforeAll
29+
public static void beforeAll() {
30+
// Do nothing
31+
}
32+
33+
/**
34+
* This will run before EVERY @Test that extends this class
35+
* The method will create a new instance of WebDriver and a browser and open Google.com
36+
* This ensures we always have a fresh browser window and a guaranteed starting point
37+
* @throws IOException if results directory isn't created or config file cannot be found
38+
*/
39+
@BeforeEach
40+
public void setUp() throws SauceLabsCredentialsException {
41+
ConfiguredDriver sauceLabsDriver = new ConfiguredSauceLabsGridDriver();
42+
this.webDriver = new EventFiringWebDriver(sauceLabsDriver.getRemoteDriver());
43+
this.webDriver.register(new WebDriverListener());
44+
this.webDriver.get(TestConfigHelper.get().getBaseUrl());
45+
this.webDriver.manage().window().maximize();
46+
}
47+
48+
/**
49+
* This will run after EVERY @Test that extends this class
50+
* The method will close the current browser and WebDriver instance down
51+
* This ensures we have cleaned up after ourselves (this happens even if the test fails)
52+
*/
53+
@AfterEach
54+
public void tearDown() {
55+
this.webDriver.quit();
56+
}
57+
}

0 commit comments

Comments
 (0)