Skip to content

Commit

Permalink
General update of the first version of the UI testing framework
Browse files Browse the repository at this point in the history
  • Loading branch information
eataborda committed Sep 2, 2024
1 parent 8495340 commit d8c5e3b
Show file tree
Hide file tree
Showing 9 changed files with 13 additions and 28 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/automation-ui-test-run.yml
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ jobs:
chrome-version: 128
install-chromedriver: true
- name: Gradle run
run: ./gradlew -DincludeTags="regression" -Ddriver="chrome" -DdriverArguments="--headless=new;--window-size=1920,1080;" -DshowAllureAttachments="true"
run: ./gradlew -DincludeTags="regression" -Ddriver="chrome" -DdriverArguments="--headless=new;--window-size=1920,1080;"
- name: Load test report history
uses: actions/checkout@v3
if: always()
Expand Down
13 changes: 11 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,15 +1,16 @@
[![automation-ui-test-run](https://github.com/eataborda/ui-selenium/actions/workflows/automation-ui-test-run.yml/badge.svg)](https://github.com/eataborda/ui-selenium/actions/workflows/automation-ui-test-run.yml)
[![Gradle](https://img.shields.io/badge/Gradle-8.9-blue)](https://gradle.org/releases/)
[![Junit5](https://img.shields.io/badge/Junit5-5.10.3-blue)](https://mvnrepository.com/artifact/org.junit.jupiter/junit-jupiter-engine)
[![Selenium](https://img.shields.io/badge/Selenium-4.23.1-blue)](https://mvnrepository.com/artifact/org.seleniumhq.selenium/selenium-java)
[![Selenium](https://img.shields.io/badge/Selenium-4.24.0-blue)](https://mvnrepository.com/artifact/org.seleniumhq.selenium/selenium-java)

# Basic UI automation
A basic UI automation using Java + Junit + Selenium + Gradle. Automation
created to test the [Sauce Demo](https://www.saucedemo.com/) page

Contains:
- Basic build.gradle.kts config to execute Junit tests with Selenium
- Basic build.gradle.kts config to execute Selenium tests with Junit5
- UI automation using the POM pattern
- Allure HTML report

## Use sample project locally
- Verify that you have `Git`
Expand All @@ -34,3 +35,11 @@ In this way you can use the following tags depending on the tests you need to ru
- Class level: standard-user, locked-out-user, problem-user
- Method level (@Test): buy-items, remove-cart-items, cart-items-persistence, order-inventory-items, verify-checkout-data, login-locked-user,
login-wrong-password, inventory-item-src-issues, inventory-filter-issues

### Generate report
Once you have run the tests you can generate the Allure report by running the following command:
```
$ allure generate build/allure-results --clean
```
If the command is executed correctly you will be able to see in the root of the project a folder called `allure-report` within this directory
is the generated HTML report
1 change: 0 additions & 1 deletion build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -75,7 +75,6 @@ dependencies {
testImplementation("org.junit.jupiter:junit-jupiter-engine:5.10.3")
testImplementation(platform("io.qameta.allure:allure-bom:$allureVersion"))
testImplementation("io.qameta.allure:allure-junit5:$allureVersion")
testImplementation("com.github.automatedowl:allure-environment-writer:1.0.0")
testImplementation("org.assertj:assertj-core:3.26.3")
testImplementation("ch.qos.logback:logback-classic:1.5.6")
testImplementation("ch.qos.logback:logback-core:1.5.6")
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
package com.github.eataborda.ui.driver;

import com.github.eataborda.ui.pages.BasePage;
import com.github.eataborda.ui.resources.URL;
import org.openqa.selenium.WebDriver;
import org.openqa.selenium.chrome.ChromeDriver;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,6 @@
import com.github.eataborda.ui.resources.*;
import com.github.eataborda.ui.pages.*;
import com.github.eataborda.ui.steps.*;
import com.google.common.collect.ImmutableMap;
import io.qameta.allure.*;
import org.assertj.core.api.SoftAssertions;
import org.junit.jupiter.api.*;
Expand All @@ -14,9 +13,6 @@
import java.util.Arrays;
import java.util.List;

import static com.github.automatedowl.tools.AllureEnvironmentWriter.allureEnvironmentWriter;


@Tags(value = {@Tag(AnnotationValues.STANDARD_USER_TAG),
@Tag(AnnotationValues.SMOKE_TAG), @Tag(AnnotationValues.REGRESSION_TAG)})
@DisplayName("Standard User")
Expand All @@ -32,18 +28,6 @@ public class StandardUserTest {

ArrayList<String> itemList = new ArrayList<String>(Arrays.asList("Sauce Labs Backpack", "Sauce Labs Bolt T-Shirt", "Sauce Labs Fleece Jacket"));

@BeforeAll
static void generalConfig() {
allureEnvironmentWriter(
ImmutableMap.<String, String>builder()
.put("OS", "Linux")
.put("Distribution", "Ubuntu")
.put("Browser", "Chrome")
.put("Browser version", "128")
.build(), "/build/allure-results/"
);
}

@BeforeEach
public void setupTest() {
driver = WebDriverConfig.setupBrowser(driver);
Expand Down Expand Up @@ -117,7 +101,7 @@ public void orderInventoryItemsTest() {
SoftAssertions softAssertions = new SoftAssertions();
loginSteps.login(LoginUser.STANDARD_USER.getUser(), LoginUser.STANDARD_USER.getPassword());

//// initial list of item u
//// initial list of item
List<String> initialNameList = inventorySteps.getItemNameList();

// inventory order name z to a
Expand Down
2 changes: 0 additions & 2 deletions src/test/java/com/github/eataborda/ui/pages/BasePage.java
Original file line number Diff line number Diff line change
Expand Up @@ -13,8 +13,6 @@
import java.io.ByteArrayInputStream;
import java.io.File;
import java.io.IOException;
import java.io.InputStream;
import java.nio.file.Files;
import java.nio.file.Paths;
import java.text.DateFormat;
import java.text.SimpleDateFormat;
Expand Down
1 change: 0 additions & 1 deletion src/test/java/com/github/eataborda/ui/pages/LoginPage.java
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,6 @@ public class LoginPage extends BasePage {
private final WebDriver driver;
@FindBy(xpath = "//h3[@data-test='error']")
WebElement fieldErrorMessage;
//private final By fieldErrorMessage = By.xpath("//h3[@data-test='error']");

@FindBy(id = "user-name")
WebElement userNameTextBox;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,9 +10,7 @@ public final class AssertDescription {
public static final String COMPARE_HILO_LIST_TO_INITIAL_LIST_EQUALS = "Compare High to Low item list with initial item list and check that they are equal";
public static final String COMPARE_HILO_LIST_TO_ZA_LIST_NOT_EQUALS = "Compare High to Low item list with Z to A item list and check that they are not equal";
public static final String COMPARE_HILO_LIST_TO_LOHI_LIST_NOT_EQUALS = "Compare High to Low item list with Low to High item list and check that they are not equal";
public static final String COMPARE_AZ_LIST_TO_INITIAL_LIST_NOT_EQUALS = "Compare A to Z item list with initial item list and check that they are not equal";
public static final String COMPARE_AZ_LIST_TO_INITIAL_LIST_EQUALS = "Compare A to Z item list with initial item list and check that they are equal";

public static final String COMPARE_AZ_LIST_TO_ZA_LIST = "Compare A to Z item list with Z to A item list and check that they are not equal";
public static final String COMPARE_AZ_LIST_TO_LOHI_LIST = "Compare A to Z item list with Low to High item list and check that they are not equal";
public static final String COMPARE_AZ_LIST_TO_HILO_LIST = "Compare A to Z item list with High to Low item list and check that they are not equal";
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
package com.github.eataborda.ui.steps;

import com.github.eataborda.ui.pages.InventoryPage;
import io.qameta.allure.Attachment;
import io.qameta.allure.Step;

import java.util.ArrayList;
Expand Down

0 comments on commit d8c5e3b

Please sign in to comment.