Skip to content

Commit

Permalink
Add pipeline for scheduled tests
Browse files Browse the repository at this point in the history
  • Loading branch information
qaPaloma committed Feb 8, 2024
1 parent 3b90660 commit bbf9734
Show file tree
Hide file tree
Showing 11 changed files with 84 additions and 133 deletions.
48 changes: 48 additions & 0 deletions .github/workflows/scheduled_tests.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,48 @@
name: Scheduled Tests - PR

on:
schedule:
- cron: '15 2,11,19 * * MON-FRI'

#Cron syntax has five fields separated by a space, and each field represents a unit of time.
#minute (0-59) / hour (0-23) / day (1-31) / month (1-12 or JAN-DEC) / day week (0-6 or SUN-SAT)
#UTC

jobs:
RunTest:
runs-on: ubuntu-latest

steps:
- name: Clone project
uses: actions/checkout@v4

- name: Install Java 20
uses: actions/setup-java@v4
with:
distribution: 'oracle'
java-version: '20.0.2'
cache: 'maven'

- name: Install Chrome
uses: browser-actions/setup-chrome@latest

- name: Install Chrome Driver
uses: actions/checkout@v2
- run: |
export DISPLAY=:99
chromedriver --url-base=/wd/hub &
sudo Xvfb -ac :99 -screen 0 1280x1024x24 > /dev/null 2>&1 & # optional
- name: Run tests
run: mvn test -Dtest=RunCucumberTest -Dbrowser=chrome-headless

- name: Generate reports
if: always()
run: mvn cluecumber-report:reporting

- name: File report artifacts
if: always()
uses: actions/upload-artifact@v4
with:
name: report-tests
path: '**/formated-report/'
File renamed without changes.
1 change: 0 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -81,7 +81,6 @@ On the terminal, type:
- Signup
- Successful signup
- Signup with existing user
- Delete account

## GitHub Actions

Expand Down
41 changes: 25 additions & 16 deletions pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -9,9 +9,19 @@
<version>1.0-SNAPSHOT</version>

<properties>
<java.version>20</java.version>
<!-- MAVEN COMPILER -->
<maven.compiler.source>20</maven.compiler.source>
<maven.compiler.target>20</maven.compiler.target>
<maven.compiler.source>20</maven.compiler.source>
<maven.compiler.version>3.11.0</maven.compiler.version>
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
<!-- -->
<selenium.version>4.16.1</selenium.version>
<slf4j.version>2.0.9</slf4j.version>
<apache.version>3.14.0</apache.version>
<cucumber.version>7.15.0</cucumber.version>
<surefire.version>3.2.5</surefire.version>
<trivago.version>2.9.4</trivago.version>
</properties>

<dependencies>
Expand All @@ -20,55 +30,55 @@
<dependency>
<groupId>org.seleniumhq.selenium</groupId>
<artifactId>selenium-java</artifactId>
<version>4.16.1</version>
<version>${selenium.version}</version>
</dependency>

<!-- SLF4J -->
<dependency>
<groupId>org.slf4j</groupId>
<artifactId>slf4j-api</artifactId>
<version>2.0.9</version>
<version>${slf4j.version}</version>
</dependency>

<dependency>
<groupId>org.slf4j</groupId>
<artifactId>slf4j-simple</artifactId>
<version>2.0.9</version>
<version>${slf4j.version}</version>
</dependency>

<!-- APACHE COMMONS LANG -->
<dependency>
<groupId>org.apache.commons</groupId>
<artifactId>commons-lang3</artifactId>
<version>3.14.0</version>
<version>${apache.version}</version>
</dependency>

<!-- CUCUMBER -->
<dependency>
<groupId>io.cucumber</groupId>
<artifactId>cucumber-junit</artifactId>
<version>7.15.0</version>
<version>${cucumber.version}</version>
<scope>test</scope>
</dependency>

<dependency>
<groupId>io.cucumber</groupId>
<artifactId>cucumber-java</artifactId>
<version>7.15.0</version>
<version>${cucumber.version}</version>
</dependency>

<!-- REPORTS -->

<dependency>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-surefire-plugin</artifactId>
<version>3.2.5</version>
<version>${surefire.version}</version>
</dependency>

<dependency>
<groupId>com.trivago.rta</groupId>
<artifactId>cluecumber-report-plugin</artifactId>
<version>2.9.4</version>
<version>${trivago.version}</version>
</dependency>
</dependencies>

Expand All @@ -77,11 +87,11 @@
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-compiler-plugin</artifactId>
<version>3.11.0</version>
<version>${maven.compiler.version}</version>
<configuration>
<encoding>UTF-8</encoding>
<source>20</source>
<target>20</target>
<encoding>${project.build.sourceEncoding}</encoding>
<source>${maven.compiler.source}</source>
<target>${maven.compiler.source}</target>
<includes>
<include>src/test/java</include>
</includes>
Expand All @@ -91,7 +101,7 @@
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-surefire-plugin</artifactId>
<version>3.2.5</version>
<version>${surefire.version}</version>
<configuration>
<testFailureIgnore>false</testFailureIgnore>
</configuration>
Expand All @@ -100,7 +110,7 @@
<plugin>
<groupId>com.trivago.rta</groupId>
<artifactId>cluecumber-report-plugin</artifactId>
<version>2.9.4</version>
<version>${trivago.version}</version>
<executions>
<execution>
<id>report</id>
Expand All @@ -115,7 +125,6 @@
<generatedHtmlReportDirectory>target/formated-report</generatedHtmlReportDirectory>
</configuration>
</plugin>

</plugins>
</build>
</project>
17 changes: 0 additions & 17 deletions src/test/java/pages/CreateAccountPage.java
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,6 @@
import static support.Commands.*;
import static support.UserDataUtils.*;
import static pages.LoginSignupPage.*;
import static pages.HomePage.*;

public class CreateAccountPage extends RunBase {

Expand Down Expand Up @@ -39,10 +38,6 @@ public class CreateAccountPage extends RunBase {
public static final String GET_PASSWORD = getRandomPassword();
//endregion

public static void openPage() {
enterWebPage(URL);
}

public void pageCheck() {
checkElementIsDisplayed(CREATE_ACCOUNT_BUTTON);
}
Expand Down Expand Up @@ -161,16 +156,4 @@ public void addUserData() {
addMobileNumber();
}

public void completeSignup() {
openPage();
clickSignupLoginButton();
pageCheck();
addName();
addSignupEmail();
clickSignupButton();
addUserData();
clickCreateButton();
HomePage.accountCreatedConfirmation();
}

}
18 changes: 4 additions & 14 deletions src/test/java/pages/HomePage.java
Original file line number Diff line number Diff line change
Expand Up @@ -10,15 +10,13 @@ public class HomePage extends RunBase {
//region constants
public static final String URL = "https://automationexercise.com/";
private static final By LOGIN_SIGNUP_BUTTON = By.xpath("//*[@id=\"header\"]/div/div/div/div[2]/div/ul/li[4]/a");
private final String PAGE_TITLE = "Automation Exercise";
private static final String HOME_PAGE_TEXT_EXPECTED = "FEATURES ITEMS";
private static final By HOME_PAGE_TEXT_ACTUAL = By.xpath("/html/body/section[2]/div/div/div[2]/div[1]/h2");
public final By LOGOUT_BUTTON = By.xpath("//*[@id=\"header\"]/div/div/div/div[2]/div/ul/li[4]/a");
private static final By NAME_ACTUAL = By.xpath("//*[@id=\"header\"]/div/div/div/div[2]/div/ul/li[10]/a/b");
private static final String NAME_EXPECTED = storeFullName();
private static final By IFRAME = By.cssSelector("#aswift_1");
private static final By IFRAME_DISMISS = By.cssSelector("#dismiss-button");
private final By DELETE_BUTTON = By.xpath("//*[@id=\"header\"]/div/div/div/div[2]/div/ul/li[5]/a");
private final String ACCOUNT_DELETED_TEXT_EXPECTED = "ACCOUNT DELETED!";
private final By ACCOUNT_DELETED_TEXT_ACTUAL = By.xpath("//*[@id=\"form\"]/div/div/div/h2/b");
private static final String ACCOUNT_CREATED_TEXT_EXPECTED = "ACCOUNT CREATED!";
private static final By ACCOUNT_CREATED_TEXT_ACTUAL = By.xpath("//*[@id=\"form\"]/div/div/div/h2/b");
private final By USER_IS_LOGGED = By.xpath("//*[@id=\"header\"]/div/div/div/div[2]/div/ul/li[10]/a");
Expand All @@ -30,7 +28,8 @@ public static void openPage() {
}

public void pageCheck() {
checkPageTitle(PAGE_TITLE);
checkElementIsCorrect(
HOME_PAGE_TEXT_ACTUAL, HOME_PAGE_TEXT_EXPECTED);
}

public static void clickSignupLoginButton() {
Expand All @@ -41,15 +40,6 @@ public void clickLogoutButton() {
clickButton(LOGOUT_BUTTON);
}

public void deleteButton() {
clickButton(DELETE_BUTTON);
}

public void deleteConfirmation() {
checkElementIsCorrect(
ACCOUNT_DELETED_TEXT_ACTUAL, ACCOUNT_DELETED_TEXT_EXPECTED);
clickButton(CONTINUE_BUTTON);
}

public static void accountCreatedConfirmation() {
checkElementIsCorrect(ACCOUNT_CREATED_TEXT_ACTUAL, ACCOUNT_CREATED_TEXT_EXPECTED);
Expand Down
7 changes: 0 additions & 7 deletions src/test/java/pages/LoginSignupPage.java
Original file line number Diff line number Diff line change
Expand Up @@ -38,13 +38,6 @@ public void addLoginPassword(String password) {
fillField(PASSWORD_FIELD, password);
}

public void tryLoginWithDeleteAccount() {
fillField(LOGIN_EMAIL_FIELD, storeEmail());
fillField(PASSWORD_FIELD, GET_PASSWORD);
clickLoginButton();
checkElementIsDisplayed(ERROR_MESSAGE);
}

public void clickLoginButton() {
clickButton(LOGIN_BUTTON);
}
Expand Down
2 changes: 1 addition & 1 deletion src/test/java/runner/RunCucumberTest.java
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
@CucumberOptions(
plugin = {"html:target/formated-report/report.html", "json:target/formated-report/report.json"},
features = "src/test/resources/features",
tags = "@login-success",
//tags = "@ignore",
glue = {"steps"}
)

Expand Down
54 changes: 0 additions & 54 deletions src/test/java/steps/DeleteAccountSteps.java

This file was deleted.

19 changes: 6 additions & 13 deletions src/test/java/support/Commands.java
Original file line number Diff line number Diff line change
Expand Up @@ -63,16 +63,16 @@ public static void enterWebPage(String URL) {
public static void selectOption(By element1, By element2){
System.out.println("##########################");
System.out.println("Will select an option");
String option = String.valueOf(UserDataUtils.getRandomNumber(2, 3));
System.out.println(option);
String option = String.valueOf(UserDataUtils.getRandomNumber(1, 2));
System.out.println("Selected option " + option);
switch (option) {
case "1":
clickButton(element1);
String selected1 = element1.toString();
//String selected1 = element1.toString();
break;
case "2":
clickButton(element2);
String selected2 = element2.toString();
//String selected2 = element2.toString();
break;
default:
System.out.println("**** Element not found");
Expand All @@ -81,12 +81,12 @@ public static void selectOption(By element1, By element2){

/*---------*/
public static void dismissIFrame(By element1, By element2){
getWait();
System.out.println("##########################");
System.out.println("Will try to locate and dismiss add");
try {
getWait();
waitElement(element1);
getDriver().switchTo().frame(getDriver().findElement(element1));
waitElement(element2);
getDriver().findElement(element2).click();
getDriver().switchTo().defaultContent();
} catch (Exception error) {
Expand Down Expand Up @@ -122,13 +122,6 @@ public static void checkElementIsDisplayed(By element){
assert elementDisplayed.isDisplayed() : "**** Element is not displayed";
}

/*---------*/
public static void checkPageTitle (String elementExpected){
String elementActual = getDriver().getTitle();
Assert.assertEquals(elementExpected, elementActual);
}

/*---------*/
public static boolean elementException(By element) {
try {
WebElement elementDisplayed = getDriver().findElement(element);
Expand Down
Loading

0 comments on commit bbf9734

Please sign in to comment.