Skip to content

Commit

Permalink
small refactoring
Browse files Browse the repository at this point in the history
  • Loading branch information
dtuchs committed Aug 17, 2024
1 parent 6818ed4 commit b4f42a9
Show file tree
Hide file tree
Showing 8 changed files with 41 additions and 11 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/e2e.yml
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ jobs:
: # build backends with profile `docker`, only for testing
bash ./gradlew jibDockerBuild -x :niffler-e-2-e-tests:test || exit 1
: # pull browser (see browsers.json)
docker pull selenoid/vnc_chrome:125.0
docker pull selenoid/vnc_chrome:127.0
: # run e2e tests
docker compose -f docker-compose.test.yml up -d
docker ps -a
Expand Down
2 changes: 1 addition & 1 deletion docker-compose-e2e.sh
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,6 @@ fi

bash ./gradlew jibDockerBuild -x :niffler-e-2-e-tests:test

docker pull selenoid/vnc_chrome:125.0
docker pull selenoid/vnc_chrome:127.0
docker compose -f docker-compose.test.yml up -d
docker ps -a
4 changes: 2 additions & 2 deletions docker-compose.test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -128,7 +128,7 @@ services:

selenoid:
container_name: selenoid
image: aerokube/selenoid:1.11.2
image: aerokube/selenoid:1.11.3
platform: linux/${ARCH}
volumes:
- ./selenoid:/etc/selenoid
Expand Down Expand Up @@ -174,7 +174,7 @@ services:

allure:
container_name: allure
image: frankescobar/allure-docker-service:2.21.0
image: frankescobar/allure-docker-service:2.27.0
depends_on:
- niffler-e-2-e
environment:
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,8 @@ private DockerConfig() {
Configuration.remote = "http://selenoid:4444/wd/hub";
Configuration.timeout = 10000;
Configuration.browser = "chrome";
Configuration.browserVersion = "125.0";
Configuration.browserVersion = "127.0";
Configuration.pageLoadStrategy = "eager";
Configuration.browserCapabilities = new ChromeOptions().addArguments("--no-sandbox");
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@ private LocalConfig() {
static {
Configuration.browserSize = "1980x1024";
Configuration.browser = "chrome";
Configuration.pageLoadStrategy = "eager";
Configuration.browserCapabilities = new ChromeOptions().addArguments("--no-sandbox");
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,20 +5,38 @@
import io.qameta.allure.Allure;
import org.junit.jupiter.api.extension.AfterEachCallback;
import org.junit.jupiter.api.extension.ExtensionContext;
import org.junit.jupiter.api.extension.LifecycleMethodExecutionExceptionHandler;
import org.junit.jupiter.api.extension.TestExecutionExceptionHandler;
import org.openqa.selenium.OutputType;
import org.openqa.selenium.TakesScreenshot;

import java.io.ByteArrayInputStream;

public class BrowserExtension implements TestExecutionExceptionHandler, AfterEachCallback {
public class BrowserExtension implements
TestExecutionExceptionHandler,
LifecycleMethodExecutionExceptionHandler,
AfterEachCallback {

@Override
public void handleTestExecutionException(ExtensionContext context, Throwable throwable) throws Throwable {
if (WebDriverRunner.hasWebDriverStarted()) {
Allure.addAttachment("Screenshot on fail",
new ByteArrayInputStream(((TakesScreenshot) WebDriverRunner.getWebDriver())
.getScreenshotAs(OutputType.BYTES)));
doScreen();
}
throw throwable;
}

@Override
public void handleBeforeEachMethodExecutionException(ExtensionContext context, Throwable throwable) throws Throwable {
if (WebDriverRunner.hasWebDriverStarted()) {
doScreen();
}
throw throwable;
}

@Override
public void handleAfterEachMethodExecutionException(ExtensionContext context, Throwable throwable) throws Throwable {
if (WebDriverRunner.hasWebDriverStarted()) {
doScreen();
}
throw throwable;
}
Expand All @@ -29,4 +47,10 @@ public void afterEach(ExtensionContext context) {
Selenide.closeWebDriver();
}
}

private void doScreen() {
Allure.addAttachment("Screenshot on fail",
new ByteArrayInputStream(((TakesScreenshot) WebDriverRunner.getWebDriver())
.getScreenshotAs(OutputType.BYTES)));
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -29,8 +29,8 @@ public SpendingTable getSpendingTable() {
@Override
public MainPage waitForPageLoaded() {
header.getSelf().should(visible).shouldHave(text("Niffler"));
spendingTable.getSelf().should(visible).shouldHave(text("History of Spendings"));
statComponent.getSelf().should(visible).shouldHave(text("Statistics"));
spendingTable.getSelf().should(visible).shouldHave(text("History of Spendings"));
return this;
}
}
6 changes: 5 additions & 1 deletion selenoid/browsers.json
Original file line number Diff line number Diff line change
@@ -1,10 +1,14 @@
{
"chrome": {
"default": "125.0",
"default": "127.0",
"versions": {
"125.0": {
"image": "selenoid/vnc_chrome:125.0",
"port": "4444"
},
"127.0": {
"image": "selenoid/vnc_chrome:127.0",
"port": "4444"
}
}
}
Expand Down

0 comments on commit b4f42a9

Please sign in to comment.