Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
95 changes: 78 additions & 17 deletions .github/workflows/ci.yaml
Original file line number Diff line number Diff line change
@@ -1,35 +1,96 @@
name: CI
name: Java CI with Maven

on:
pull_request:
branches: [main]
branches:
- main
push:
branches:
- main

jobs:
run-test:
build:
name: 'Run tests'
runs-on: ubuntu-latest

steps:
# 1. Cloning
- name: Git clone
uses: actions/checkout@v3
with:
fetch-depth: 0
uses: actions/checkout@v4

- name: Install JDK
uses: actions/setup-java@v3
# 2. Install Java 17
- name: Setup JDK 17
uses: actions/setup-java@v4
with:
distribution: 'corretto'
java-version: '17'
distribution: 'corretto'
cache: 'maven'

- name: Get list of changed files
run: echo "LIST_OF_CHANGED_FILES=$(git diff --name-only origin/$GITHUB_HEAD_REF $(git merge-base origin/$GITHUB_HEAD_REF origin/main) | tr '\n' ';')" >> $GITHUB_ENV
# 3. Run tests (not stop workflow if failure )
- name: Build and run tests with Maven
run: mvn -B -e clean test -Dselenium.headless=true || true
env:
CHROME_OPTIONS: --remote-allow-origins=*;--disable-gpu;--no-sandbox;--disable-dev-shm-usage;--headless=new;--window-size=1920,1080

- name: Attach screenshots and reports
uses: actions/upload-artifact@v3
# 4. Output failed tests
- name: Print failed tests
if: failure()
run: |
echo "---- TEST FAILURES ----"
cat target/surefire-reports/*.txt || true

# 5. Attach screenshots
- name: Attach screenshots
if: always()
uses: actions/upload-artifact@v4
with:
name: screenshots
path: ${{ github.workspace }}/screenshots

# 6. Get Allure (gh-pages)
- name: Get Allure history
uses: actions/checkout@v4
if: always()
continue-on-error: true
with:
ref: gh-pages
path: gh-pages

# 7. Build Allure report
- name: Build Allure report
uses: simple-elf/allure-report-action@master
if: always()
id: allure-report
with:
allure_results: target/allure-results
gh_pages: gh-pages
allure_report: allure-report
allure_history: allure-history

# 8. Upload Allure report artifact
- name: Upload Allure report artifact
if: always()
uses: actions/upload-artifact@v4
with:
name: allure-report
path: target/allure-report

# 9. Check allure-results
- name: Check Allure results
run: ls -la target/allure-results

# 10. Publish Allure to GitHub Pages
- name: Publish Allure report to Github Pages
if: always()
uses: peaceiris/actions-gh-pages@v2
env:
PERSONAL_TOKEN: ${{ secrets.GITHUB_TOKEN }}
PUBLISH_BRANCH: gh-pages
PUBLISH_DIR: allure-history

- name: Upload Allure HTML report as artifact
if: always()
uses: actions/upload-artifact@v4
with:
name: screenshots-and-report
path: |
screenshots
target/surefire-reports/emailable-report.html
name: allure-report
path: allure-report
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ target/
*.iws
*.iml
*.ipr
'.idea/workspace.xml

### Eclipse ###
.apt_generated
Expand Down
38 changes: 20 additions & 18 deletions .idea/workspace.xml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

51 changes: 51 additions & 0 deletions pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -12,9 +12,22 @@
<properties>
<maven.compiler.source>17</maven.compiler.source>
<maven.compiler.target>17</maven.compiler.target>
<allure.version>2.24.0</allure.version>
<aspectj.version>1.9.22</aspectj.version>
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
</properties>

<dependencyManagement>
<dependencies>
<dependency>
<groupId>io.qameta.allure</groupId>
<artifactId>allure-bom</artifactId>
<version>${allure.version}</version>
<type>pom</type>
<scope>import</scope>
</dependency>
</dependencies>
</dependencyManagement>

<dependencies>
<dependency>
Expand All @@ -35,8 +48,46 @@
<scope>test</scope>
</dependency>

<dependency>
<groupId>io.qameta.allure</groupId>
<artifactId>allure-testng</artifactId>
<scope>test</scope>
</dependency>

</dependencies>

<build>
<plugins>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-surefire-plugin</artifactId>
<version>3.1.2</version>
<configuration>
<argLine>
-javaagent:"${settings.localRepository}/org/aspectj/aspectjweaver/${aspectj.version}/aspectjweaver-${aspectj.version}.jar"
</argLine>
</configuration>
<dependencies>
<dependency>
<groupId>org.aspectj</groupId>
<artifactId>aspectjweaver</artifactId>
<!--suppress UnresolvedMavenProperty -->
<version>${aspectj.version}</version>
</dependency>
</dependencies>
</plugin>
<!-- Allure plugin -->
<plugin>
<groupId>io.qameta.allure</groupId>
<artifactId>allure-maven</artifactId>
<version>2.12.0</version>
<configuration>
<resultsDirectory>${project.build.directory}/allure-results</resultsDirectory>
</configuration>
</plugin>
</plugins>

</build>

</project>

6 changes: 4 additions & 2 deletions src/test/java/automatiom/tests/ElementsPage.java
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@

import automatiom.tests.base.BaseConfigurationPage;
import automatiom.tests.base.BasePage;
import io.qameta.allure.Step;
import org.openqa.selenium.WebDriver;
import org.openqa.selenium.WebElement;
import org.openqa.selenium.support.FindBy;
Expand All @@ -25,7 +26,7 @@ public ElementsTextBoxPage clickGotoNewPage() {
}


@FindBy(xpath ="//div[@class = 'accordion']//div[@class='element-group'][1]")
@FindBy(xpath = "//div[@class = 'accordion']//div[@class='element-group'][1]")
WebElement sectionElements;

@FindBy(xpath = "//span[contains(text(), 'Text Box')]")
Expand All @@ -36,6 +37,7 @@ public String getUrlOfPage() {
return getDriver().getCurrentUrl();
}

@Step("Show elements content")
public ElementsPage showElementsContent() {
sectionElements.click();
getDriver().navigate().back();
Expand All @@ -44,11 +46,11 @@ public ElementsPage showElementsContent() {
return this;
}

@Step("Show text box")
public ElementsTextBoxPage showTextBoxText() {
getTextBox.click();
return new ElementsTextBoxPage(getDriver());
}



}
10 changes: 9 additions & 1 deletion src/test/java/automatiom/tests/tests/ElementsPageTest.java
Original file line number Diff line number Diff line change
Expand Up @@ -4,9 +4,15 @@
import automatiom.tests.ElementsTextBoxPage;
import automatiom.tests.HomePage;
import automatiom.tests.runner.BaseTest;
import io.qameta.allure.Epic;
import io.qameta.allure.Feature;
import io.qameta.allure.Story;
import org.testng.Assert;
import org.testng.annotations.Test;

@Epic("Selenium elements")
@Feature("Elements")

public class ElementsPageTest extends BaseTest {

private static final String ELEMENTS_PAGE = "https://demoqa.com/elements";
Expand All @@ -19,7 +25,7 @@ public class ElementsPageTest extends BaseTest {
private ElementsTextBoxPage titleOfTextBoxElementsPage;


@Test()
@Test
public void testGetTitle() {
String homePage = new HomePage(getDriver())
.accetpCookies()
Expand All @@ -44,6 +50,7 @@ public void testGoToElementsPage() {


@Test
@Story("Text box")
public void testVerifyTextBox() {
String titleOfTextBoxElementsPage = new HomePage(getDriver())
.accetpCookies()
Expand All @@ -58,6 +65,7 @@ public void testVerifyTextBox() {
}

@Test
@Story("Text box")
public void testVerifyTextBoxForm() {
String titleOfTextBoxElementsPage = new HomePage(getDriver())
.accetpCookies()
Expand Down
1 change: 1 addition & 0 deletions src/test/resources/allure.properties
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
allure.results.directory=target/allure-results
Loading