From bffcc10e99bb74b7a416366d45ba46503614c385 Mon Sep 17 00:00:00 2001 From: Aleksandr_Vorobev Date: Tue, 26 Dec 2023 15:59:07 +0300 Subject: [PATCH 01/28] jdn-template-selenide init --- README.md | 1 + pom.xml | 159 ++++++++++++++++++ src/main/java/site/MySite.java | 15 ++ src/main/java/site/pages/FirstPage.java | 11 ++ .../java/testng/RetryFailedTestCases.java | 26 +++ src/test/java/testng/RetryListenerClass.java | 19 +++ src/test/java/testng/TestNGListener.java | 69 ++++++++ src/test/java/tests/ExampleTests.java | 14 ++ src/test/java/tests/TestsInit.java | 25 +++ src/test/resources/chrome.properties | 2 + src/test/resources/common.properties | 1 + src/test/resources/general.xml | 13 ++ src/test/resources/log4j2.xml | 61 +++++++ src/test/resources/test.properties | 33 ++++ 14 files changed, 449 insertions(+) create mode 100644 pom.xml create mode 100644 src/main/java/site/MySite.java create mode 100644 src/main/java/site/pages/FirstPage.java create mode 100644 src/test/java/testng/RetryFailedTestCases.java create mode 100644 src/test/java/testng/RetryListenerClass.java create mode 100644 src/test/java/testng/TestNGListener.java create mode 100644 src/test/java/tests/ExampleTests.java create mode 100644 src/test/java/tests/TestsInit.java create mode 100644 src/test/resources/chrome.properties create mode 100644 src/test/resources/common.properties create mode 100644 src/test/resources/general.xml create mode 100644 src/test/resources/log4j2.xml create mode 100644 src/test/resources/test.properties diff --git a/README.md b/README.md index 22ec999..73f9aee 100644 --- a/README.md +++ b/README.md @@ -1,2 +1,3 @@ # jdn-template-selenide Template project for JDN with Selenide +x \ No newline at end of file diff --git a/pom.xml b/pom.xml new file mode 100644 index 0000000..fe177d2 --- /dev/null +++ b/pom.xml @@ -0,0 +1,159 @@ + + + 4.0.0 + + com.epam.jdi + jdi-light-testng-empty-template + 1.0.0 + Template: JDI Light TestNG Testing project + + + chrome + UTF-8 + 1.9.7 + https://jdi-testing.github.io/jdi-light/ + 7.8.0 + 2.23.0 + 2.12.0 + 9.4.12.RC2 + RELEASE + + https://jdi-testing.github.io/jdi-light/ + + INFO + + + + + + + jdk16 + + [16, 20] + + + --add-opens java.base/java.lang=ALL-UNNAMED + + + + + ci + + false + + + http://localhost:4444/wd/hub + INFO + + + + + + + + com.epam.jdi + jdi-light-html + ${jdi.version} + + + + + + + + + io.qameta.allure + allure-testng + ${allure.testng} + test + + + org.testng + testng + + + io.qameta.allure + allure-java-commons + + + + + + org.testng + testng + ${testng.version} + test + + + + + + + org.apache.maven.plugins + maven-compiler-plugin + 3.8.1 + + 11 + 11 + + + + org.apache.maven.plugins + maven-surefire-plugin + 2.22.2 + + + ${project.build.directory}/allure-results + + + src/test/resources/general.xml + + + ${aspectj.args} + -javaagent:"${settings.localRepository}/org/aspectj/aspectjweaver/${aspectj.version}/aspectjweaver-${aspectj.version}.jar" + + + + + org.aspectj + aspectjweaver + ${aspectj.version} + + + + + io.qameta.allure + allure-maven + ${allure.maven} + + 2.10.0 + + + + + + + ${project.basedir}/src/main/resources + + + src/test/resources + true + + + + + diff --git a/src/main/java/site/MySite.java b/src/main/java/site/MySite.java new file mode 100644 index 0000000..4c6917a --- /dev/null +++ b/src/main/java/site/MySite.java @@ -0,0 +1,15 @@ +package site; + +import com.epam.jdi.light.elements.pageobjects.annotations.Url; +import site.pages.*; + +public class MySite { + //region Example page description - to be removed + // This is an example of Url definition for the page (not required) + //@Url("{ENTER_HOME_PAGE_URL}") + // This is an example of Page description in the Site + public static FirstPage firstPage; + //endregion + + // ADD SITE PAGES WITH URLS +} diff --git a/src/main/java/site/pages/FirstPage.java b/src/main/java/site/pages/FirstPage.java new file mode 100644 index 0000000..d681de5 --- /dev/null +++ b/src/main/java/site/pages/FirstPage.java @@ -0,0 +1,11 @@ +package site.pages; + +import com.epam.jdi.light.elements.composite.WebPage; +import com.epam.jdi.light.elements.pageobjects.annotations.locators.UI; +import com.epam.jdi.light.ui.html.elements.common.Button; + +// This is an example of Page Object definition. To be removed +public class FirstPage extends WebPage { + @UI("//button") + public static Button testButton; +} diff --git a/src/test/java/testng/RetryFailedTestCases.java b/src/test/java/testng/RetryFailedTestCases.java new file mode 100644 index 0000000..6973560 --- /dev/null +++ b/src/test/java/testng/RetryFailedTestCases.java @@ -0,0 +1,26 @@ +package testng; + +import org.testng.IRetryAnalyzer; +import org.testng.ITestResult; + +import static com.epam.jdi.light.settings.WebSettings.logger; + +public class RetryFailedTestCases implements IRetryAnalyzer { + private int retryCnt = 0; + + // This method will be called everytime a test fails. + // It will return TRUE if a test fails and need to be retried, else it returns FALSE + public boolean retry(ITestResult result) { + // You could mention maxRetryCnt (Maximiun Retry Count) as per your requirement. + // Here I took 2, If any failed testcases then it runs two times + int maxRetryCnt = 1; + if (retryCnt < maxRetryCnt) { + logger.info("Retrying " + result.getName() + " again and the count is " + (retryCnt+1)); + retryCnt++; + return true; + } + return false; + } + +} + diff --git a/src/test/java/testng/RetryListenerClass.java b/src/test/java/testng/RetryListenerClass.java new file mode 100644 index 0000000..7fd6073 --- /dev/null +++ b/src/test/java/testng/RetryListenerClass.java @@ -0,0 +1,19 @@ +package testng; + +import org.testng.IAnnotationTransformer; +import org.testng.annotations.ITestAnnotation; + +import java.lang.reflect.Constructor; +import java.lang.reflect.Method; + +public class RetryListenerClass implements IAnnotationTransformer { + + @Override + public void transform(ITestAnnotation testannotation, Class testClass, Constructor testConstructor, Method testMethod) { + Class retry = testannotation.getRetryAnalyzerClass(); + if (retry == null) { + testannotation.setRetryAnalyzer(RetryFailedTestCases.class); + } + + } +} diff --git a/src/test/java/testng/TestNGListener.java b/src/test/java/testng/TestNGListener.java new file mode 100644 index 0000000..7f4c2ea --- /dev/null +++ b/src/test/java/testng/TestNGListener.java @@ -0,0 +1,69 @@ +package testng; + +/** + * Created by Roman Iovlev on 14.02.2018 + * Email: roman.iovlev.jdi@gmail.com; Skype: roman.iovlev + */ + +import com.jdiai.tools.Safe; +import org.testng.IInvokedMethod; +import org.testng.IInvokedMethodListener; +import org.testng.ITestNGMethod; +import org.testng.ITestResult; +import org.testng.annotations.Test; + +import java.text.SimpleDateFormat; +import java.util.Date; + +import static com.epam.jdi.light.driver.ScreenshotMaker.takeScreen; +import static com.epam.jdi.light.settings.WebSettings.TEST_NAME; +import static com.epam.jdi.light.settings.WebSettings.logger; +import static com.jdiai.tools.LinqUtils.last; +import static java.lang.System.currentTimeMillis; + +public class TestNGListener implements IInvokedMethodListener { private Safe start = new Safe<>(0L); + + @Override + public void beforeInvocation(IInvokedMethod m, ITestResult tr) { + if (m.isTestMethod()) { + ITestNGMethod testMethod = m.getTestMethod(); + if (testMethod.getConstructorOrMethod().getMethod().isAnnotationPresent(Test.class)) { + TEST_NAME.set( last(testMethod.getTestClass().getName().split("\\.")) + + "." + testMethod.getMethodName()); + start.set(currentTimeMillis()); + logger.step("== Test '%s' START ==", TEST_NAME.get()); + } + } + } + + @Override + public void afterInvocation(IInvokedMethod method, ITestResult tr) { + if (method.isTestMethod()) { + String result = getTestResult(tr); + logger.step("=== Test '%s' %s [%s] ===", TEST_NAME.get(), result, + new SimpleDateFormat("mm:ss.SS") + .format(new Date(currentTimeMillis() - start.get()))); + if ("FAILED".equals(result)) { + try { + takeScreen(); + } catch (RuntimeException ignored) { } + if (tr.getThrowable() != null) { + logger.step("ERROR: " + tr.getThrowable().getMessage()); + } else { + logger.step("UNKNOWN ERROR"); + } + } + } + } + + private String getTestResult(ITestResult result) { + switch (result.getStatus()) { + case ITestResult.SUCCESS: + return "PASSED"; + case ITestResult.SKIP: + return "SKIPPED"; + default: + return "FAILED"; + } + } +} \ No newline at end of file diff --git a/src/test/java/tests/ExampleTests.java b/src/test/java/tests/ExampleTests.java new file mode 100644 index 0000000..2a1adc5 --- /dev/null +++ b/src/test/java/tests/ExampleTests.java @@ -0,0 +1,14 @@ +package tests; + +import org.testng.annotations.Test; + +import site.MySite; + +public class ExampleTests implements TestsInit { + + @Test + public void openPageTest() { + MySite.firstPage.open(); + MySite.firstPage.checkOpened(); + } +} diff --git a/src/test/java/tests/TestsInit.java b/src/test/java/tests/TestsInit.java new file mode 100644 index 0000000..ea10395 --- /dev/null +++ b/src/test/java/tests/TestsInit.java @@ -0,0 +1,25 @@ +package tests; + +import testng.TestNGListener; +import site.MySite; +import org.testng.annotations.AfterSuite; +import org.testng.annotations.BeforeSuite; +import org.testng.annotations.Listeners; + +import static com.epam.jdi.light.driver.WebDriverUtils.killAllSeleniumDrivers; +import static com.epam.jdi.light.elements.init.PageFactory.initSite; +import static com.epam.jdi.light.settings.WebSettings.logger; + +@Listeners(TestNGListener.class) +public interface TestsInit { + @BeforeSuite(alwaysRun = true) + public default void setUp() { + initSite(MySite.class); + logger.info("Run Tests"); + } + + @AfterSuite(alwaysRun = true) + public default void teardown() { + killAllSeleniumDrivers(); + } +} diff --git a/src/test/resources/chrome.properties b/src/test/resources/chrome.properties new file mode 100644 index 0000000..b4f7d89 --- /dev/null +++ b/src/test/resources/chrome.properties @@ -0,0 +1,2 @@ +#arguments=--ignore-certificate-errors --start-maximized --incognito +#enableVNC=true \ No newline at end of file diff --git a/src/test/resources/common.properties b/src/test/resources/common.properties new file mode 100644 index 0000000..c31a28a --- /dev/null +++ b/src/test/resources/common.properties @@ -0,0 +1 @@ +arguments=--headless diff --git a/src/test/resources/general.xml b/src/test/resources/general.xml new file mode 100644 index 0000000..6acc4dd --- /dev/null +++ b/src/test/resources/general.xml @@ -0,0 +1,13 @@ + + + + + + + + + + + + + \ No newline at end of file diff --git a/src/test/resources/log4j2.xml b/src/test/resources/log4j2.xml new file mode 100644 index 0000000..6b7aec5 --- /dev/null +++ b/src/test/resources/log4j2.xml @@ -0,0 +1,61 @@ + + + + + jdiEvents + ./target/.logs + + + + + + + + + ${baseDir}/${logFileName}_%d{yyyy-MM-dd__HH-mm}_%i.log + + %d{HH:mm:ss} [%t] %-5level %logger{6} - %msg%n + + + + + + + + + + + false + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/src/test/resources/test.properties b/src/test/resources/test.properties new file mode 100644 index 0000000..0e76f23 --- /dev/null +++ b/src/test/resources/test.properties @@ -0,0 +1,33 @@ +driver=${driver} +driver.remote.url=${driver.remote.url} +timeout.wait.element=10 +domain=${domain} +page.check.after.open=NONE +# NEW_PAGE | EVERY_PAGE +#element.search.strategy=strict | soft | visible, multiple | any, single +element.search.strategy=strict +smart.locator=#%s +#smart.locator.to.name=kebab-case | camelCase | snake_case | PascalCase | UPPER_SNAKE_CASE +log.level=${log.level} +log.info.details=element +#text.type=SMART_TEXT | TEXT | VALUE | INNER | LABEL +#set.text.type=SET_TEXT | SEND_KEYS | CLEAR_SEND_KEYS +#assert.type=strict | soft + +#page.load.strategy=normal +#browser.size=MAXIMIZE | 1024x762 +#browser.kill=afterAndBefore | after | before +#drivers.folder=C:\\Selenium +#log.message.format=short | full +#demo.mode=false | true +#demo.delay=2 +#remote.type=sauce | browserstack +#driver.remote.url=http://localhost:4444/wd/hub +#headless=true | false +screenshot.strategy=on failure +#element.highlight=off | on failure | on assert | on action | flow +#screenshot.strategy=off | on failure | on assert | new page | flow +#allure.steps=true +#html.code.strategy=off | on failure | on assert | new page +#requests.strategy=off | on failure | on assert | new page +#screenshot.tool=selenium | robot \ No newline at end of file From decf9829f4b32f1bc44d717993bbe95cc3c805c6 Mon Sep 17 00:00:00 2001 From: Aleksandr_Vorobev Date: Wed, 27 Dec 2023 02:02:59 +0300 Subject: [PATCH 02/28] jdn-template-selenide init --- README.md | 1 - pom.xml | 119 +++++++++--------- src/main/java/site/MySite.java | 11 +- src/main/java/site/pages/BasePage.java | 20 +++ src/main/java/site/pages/FirstPage.java | 17 ++- src/main/resources/general.xml | 17 +++ src/{test => main}/resources/log4j2.xml | 0 src/main/resources/selenide.properties | 25 ++++ src/main/test/java/test/BaseTest.java | 34 +++++ src/main/test/java/test/ExampleTests.java | 11 ++ .../java/testng/RetryFailedTestCases.java | 26 ---- src/test/java/testng/RetryListenerClass.java | 19 --- src/test/java/testng/TestNGListener.java | 69 ---------- src/test/java/tests/ExampleTests.java | 14 --- src/test/java/tests/TestsInit.java | 25 ---- src/test/resources/chrome.properties | 2 - src/test/resources/common.properties | 1 - src/test/resources/general.xml | 13 -- src/test/resources/test.properties | 33 ----- 19 files changed, 183 insertions(+), 274 deletions(-) create mode 100644 src/main/java/site/pages/BasePage.java create mode 100644 src/main/resources/general.xml rename src/{test => main}/resources/log4j2.xml (100%) create mode 100644 src/main/resources/selenide.properties create mode 100644 src/main/test/java/test/BaseTest.java create mode 100644 src/main/test/java/test/ExampleTests.java delete mode 100644 src/test/java/testng/RetryFailedTestCases.java delete mode 100644 src/test/java/testng/RetryListenerClass.java delete mode 100644 src/test/java/testng/TestNGListener.java delete mode 100644 src/test/java/tests/ExampleTests.java delete mode 100644 src/test/java/tests/TestsInit.java delete mode 100644 src/test/resources/chrome.properties delete mode 100644 src/test/resources/common.properties delete mode 100644 src/test/resources/general.xml delete mode 100644 src/test/resources/test.properties diff --git a/README.md b/README.md index 73f9aee..22ec999 100644 --- a/README.md +++ b/README.md @@ -1,3 +1,2 @@ # jdn-template-selenide Template project for JDN with Selenide -x \ No newline at end of file diff --git a/pom.xml b/pom.xml index fe177d2..c9399d2 100644 --- a/pom.xml +++ b/pom.xml @@ -1,13 +1,12 @@ - 4.0.0 com.epam.jdi - jdi-light-testng-empty-template + jdn-template-selenide 1.0.0 - Template: JDI Light TestNG Testing project + Template: Selenide TestNG Testing project chrome @@ -15,16 +14,12 @@ 1.9.7 https://jdi-testing.github.io/jdi-light/ 7.8.0 - 2.23.0 - 2.12.0 + + 9.4.12.RC2 - RELEASE - - https://jdi-testing.github.io/jdi-light/ - + INFO - @@ -51,52 +46,58 @@ - + - com.epam.jdi - jdi-light-html - ${jdi.version} + org.apache.logging.log4j + log4j-core + 2.22.0 - - - com.epam.jdi - jdi-light-material-ui - ${jdi.version} + com.codeborne + selenide + 7.0.4 + compile - --> - - + + + + + + + + + + + + + + + + - com.epam.jdi - jdi-light-vuetify - ${jdi.version} + org.testng + testng + ${testng.version} + test - --> - - - io.qameta.allure - allure-testng - ${allure.testng} + org.projectlombok + lombok + 1.18.22 test - - - org.testng - testng - - - io.qameta.allure - allure-java-commons - - - + + com.codeborne + selenide-core + 7.0.4 + org.testng testng - ${testng.version} - test + 7.8.0 + compile @@ -107,8 +108,8 @@ maven-compiler-plugin 3.8.1 - 11 - 11 + 16 + 16 @@ -116,9 +117,9 @@ maven-surefire-plugin 2.22.2 - - ${project.build.directory}/allure-results - + + + src/test/resources/general.xml @@ -135,14 +136,14 @@ - - io.qameta.allure - allure-maven - ${allure.maven} - - 2.10.0 - - + + + + + + + + @@ -150,7 +151,7 @@ ${project.basedir}/src/main/resources - src/test/resources + src/main/resources true diff --git a/src/main/java/site/MySite.java b/src/main/java/site/MySite.java index 4c6917a..6cfd6dd 100644 --- a/src/main/java/site/MySite.java +++ b/src/main/java/site/MySite.java @@ -1,14 +1,13 @@ package site; -import com.epam.jdi.light.elements.pageobjects.annotations.Url; -import site.pages.*; +import com.codeborne.selenide.Configuration; +import site.pages.FirstPage; + +import static com.codeborne.selenide.FileDownloadMode.FOLDER; public class MySite { - //region Example page description - to be removed - // This is an example of Url definition for the page (not required) - //@Url("{ENTER_HOME_PAGE_URL}") - // This is an example of Page description in the Site public static FirstPage firstPage; + //endregion // ADD SITE PAGES WITH URLS diff --git a/src/main/java/site/pages/BasePage.java b/src/main/java/site/pages/BasePage.java new file mode 100644 index 0000000..060677e --- /dev/null +++ b/src/main/java/site/pages/BasePage.java @@ -0,0 +1,20 @@ +package site.pages; + +import com.codeborne.selenide.Selenide; + +import static com.codeborne.selenide.Selenide.open; + +// This is an example of Page Object definition. To be removed +public abstract class BasePage { + protected String PATH; + protected String TITLE; + + public BasePage(final String title, final String path) { + this.PATH = path; + this.TITLE = title; + } + + public void openPage() { + Selenide.open(this.PATH); + } +} diff --git a/src/main/java/site/pages/FirstPage.java b/src/main/java/site/pages/FirstPage.java index d681de5..710d536 100644 --- a/src/main/java/site/pages/FirstPage.java +++ b/src/main/java/site/pages/FirstPage.java @@ -1,11 +1,16 @@ package site.pages; -import com.epam.jdi.light.elements.composite.WebPage; -import com.epam.jdi.light.elements.pageobjects.annotations.locators.UI; -import com.epam.jdi.light.ui.html.elements.common.Button; +import com.codeborne.selenide.SelenideElement; + +import static com.codeborne.selenide.Selenide.$; // This is an example of Page Object definition. To be removed -public class FirstPage extends WebPage { - @UI("//button") - public static Button testButton; +public class FirstPage extends BasePage { + private static final String PATH = "/"; + private static final String TITLE = "/"; + public static SelenideElement testButton = $("button"); + + public FirstPage() { + super(TITLE, PATH); + } } diff --git a/src/main/resources/general.xml b/src/main/resources/general.xml new file mode 100644 index 0000000..478cc31 --- /dev/null +++ b/src/main/resources/general.xml @@ -0,0 +1,17 @@ + + + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/src/test/resources/log4j2.xml b/src/main/resources/log4j2.xml similarity index 100% rename from src/test/resources/log4j2.xml rename to src/main/resources/log4j2.xml diff --git a/src/main/resources/selenide.properties b/src/main/resources/selenide.properties new file mode 100644 index 0000000..36507fd --- /dev/null +++ b/src/main/resources/selenide.properties @@ -0,0 +1,25 @@ +# selenide.properties + +# Base URL +baseUrl=https://www.example.com + +# Browser type +browser=chrome + +# Page load timeout +timeout=20000 + +# Headless mode +headless=false + +# Browser size +browserSize=1920x1200 + +# Start maximized +startMaximized=true + +# Enable screenshots +screenshots=true + +# File download folder +fileDownload=FOLDER diff --git a/src/main/test/java/test/BaseTest.java b/src/main/test/java/test/BaseTest.java new file mode 100644 index 0000000..08114f5 --- /dev/null +++ b/src/main/test/java/test/BaseTest.java @@ -0,0 +1,34 @@ +package test; + +import com.codeborne.selenide.Configuration; +import com.codeborne.selenide.Selenide; +import org.testng.annotations.AfterSuite; +import org.testng.annotations.BeforeSuite; +import org.testng.annotations.Listeners; +import site.MySite; +import site.pages.FirstPage; + +import static com.codeborne.selenide.FileDownloadMode.FOLDER; + +@Listeners() +public interface BaseTest { + @BeforeSuite + public static void setUp() { + Configuration.baseUrl = "https://www.example.com"; + Configuration.browser = "chrome"; // You can also use "firefox", "edge", etc. + + // Other common configurations... + Configuration.pageLoadTimeout = 20000; + Configuration.headless = false; + Configuration.browserSize = "1920x1200"; + Configuration.screenshots = true; + Configuration.fileDownload = FOLDER; + MySite.firstPage = new FirstPage(); + } + + @AfterSuite + public static void tearDown() { + // Close all open browsers + Selenide.closeWebDriver(); + } +} diff --git a/src/main/test/java/test/ExampleTests.java b/src/main/test/java/test/ExampleTests.java new file mode 100644 index 0000000..0e4c8bf --- /dev/null +++ b/src/main/test/java/test/ExampleTests.java @@ -0,0 +1,11 @@ +package test; + +import org.testng.annotations.Test; +import site.MySite; + +public class ExampleTests implements BaseTest { + @Test + public void openPageTest() { + MySite.firstPage.openPage(); + } +} diff --git a/src/test/java/testng/RetryFailedTestCases.java b/src/test/java/testng/RetryFailedTestCases.java deleted file mode 100644 index 6973560..0000000 --- a/src/test/java/testng/RetryFailedTestCases.java +++ /dev/null @@ -1,26 +0,0 @@ -package testng; - -import org.testng.IRetryAnalyzer; -import org.testng.ITestResult; - -import static com.epam.jdi.light.settings.WebSettings.logger; - -public class RetryFailedTestCases implements IRetryAnalyzer { - private int retryCnt = 0; - - // This method will be called everytime a test fails. - // It will return TRUE if a test fails and need to be retried, else it returns FALSE - public boolean retry(ITestResult result) { - // You could mention maxRetryCnt (Maximiun Retry Count) as per your requirement. - // Here I took 2, If any failed testcases then it runs two times - int maxRetryCnt = 1; - if (retryCnt < maxRetryCnt) { - logger.info("Retrying " + result.getName() + " again and the count is " + (retryCnt+1)); - retryCnt++; - return true; - } - return false; - } - -} - diff --git a/src/test/java/testng/RetryListenerClass.java b/src/test/java/testng/RetryListenerClass.java deleted file mode 100644 index 7fd6073..0000000 --- a/src/test/java/testng/RetryListenerClass.java +++ /dev/null @@ -1,19 +0,0 @@ -package testng; - -import org.testng.IAnnotationTransformer; -import org.testng.annotations.ITestAnnotation; - -import java.lang.reflect.Constructor; -import java.lang.reflect.Method; - -public class RetryListenerClass implements IAnnotationTransformer { - - @Override - public void transform(ITestAnnotation testannotation, Class testClass, Constructor testConstructor, Method testMethod) { - Class retry = testannotation.getRetryAnalyzerClass(); - if (retry == null) { - testannotation.setRetryAnalyzer(RetryFailedTestCases.class); - } - - } -} diff --git a/src/test/java/testng/TestNGListener.java b/src/test/java/testng/TestNGListener.java deleted file mode 100644 index 7f4c2ea..0000000 --- a/src/test/java/testng/TestNGListener.java +++ /dev/null @@ -1,69 +0,0 @@ -package testng; - -/** - * Created by Roman Iovlev on 14.02.2018 - * Email: roman.iovlev.jdi@gmail.com; Skype: roman.iovlev - */ - -import com.jdiai.tools.Safe; -import org.testng.IInvokedMethod; -import org.testng.IInvokedMethodListener; -import org.testng.ITestNGMethod; -import org.testng.ITestResult; -import org.testng.annotations.Test; - -import java.text.SimpleDateFormat; -import java.util.Date; - -import static com.epam.jdi.light.driver.ScreenshotMaker.takeScreen; -import static com.epam.jdi.light.settings.WebSettings.TEST_NAME; -import static com.epam.jdi.light.settings.WebSettings.logger; -import static com.jdiai.tools.LinqUtils.last; -import static java.lang.System.currentTimeMillis; - -public class TestNGListener implements IInvokedMethodListener { private Safe start = new Safe<>(0L); - - @Override - public void beforeInvocation(IInvokedMethod m, ITestResult tr) { - if (m.isTestMethod()) { - ITestNGMethod testMethod = m.getTestMethod(); - if (testMethod.getConstructorOrMethod().getMethod().isAnnotationPresent(Test.class)) { - TEST_NAME.set( last(testMethod.getTestClass().getName().split("\\.")) + - "." + testMethod.getMethodName()); - start.set(currentTimeMillis()); - logger.step("== Test '%s' START ==", TEST_NAME.get()); - } - } - } - - @Override - public void afterInvocation(IInvokedMethod method, ITestResult tr) { - if (method.isTestMethod()) { - String result = getTestResult(tr); - logger.step("=== Test '%s' %s [%s] ===", TEST_NAME.get(), result, - new SimpleDateFormat("mm:ss.SS") - .format(new Date(currentTimeMillis() - start.get()))); - if ("FAILED".equals(result)) { - try { - takeScreen(); - } catch (RuntimeException ignored) { } - if (tr.getThrowable() != null) { - logger.step("ERROR: " + tr.getThrowable().getMessage()); - } else { - logger.step("UNKNOWN ERROR"); - } - } - } - } - - private String getTestResult(ITestResult result) { - switch (result.getStatus()) { - case ITestResult.SUCCESS: - return "PASSED"; - case ITestResult.SKIP: - return "SKIPPED"; - default: - return "FAILED"; - } - } -} \ No newline at end of file diff --git a/src/test/java/tests/ExampleTests.java b/src/test/java/tests/ExampleTests.java deleted file mode 100644 index 2a1adc5..0000000 --- a/src/test/java/tests/ExampleTests.java +++ /dev/null @@ -1,14 +0,0 @@ -package tests; - -import org.testng.annotations.Test; - -import site.MySite; - -public class ExampleTests implements TestsInit { - - @Test - public void openPageTest() { - MySite.firstPage.open(); - MySite.firstPage.checkOpened(); - } -} diff --git a/src/test/java/tests/TestsInit.java b/src/test/java/tests/TestsInit.java deleted file mode 100644 index ea10395..0000000 --- a/src/test/java/tests/TestsInit.java +++ /dev/null @@ -1,25 +0,0 @@ -package tests; - -import testng.TestNGListener; -import site.MySite; -import org.testng.annotations.AfterSuite; -import org.testng.annotations.BeforeSuite; -import org.testng.annotations.Listeners; - -import static com.epam.jdi.light.driver.WebDriverUtils.killAllSeleniumDrivers; -import static com.epam.jdi.light.elements.init.PageFactory.initSite; -import static com.epam.jdi.light.settings.WebSettings.logger; - -@Listeners(TestNGListener.class) -public interface TestsInit { - @BeforeSuite(alwaysRun = true) - public default void setUp() { - initSite(MySite.class); - logger.info("Run Tests"); - } - - @AfterSuite(alwaysRun = true) - public default void teardown() { - killAllSeleniumDrivers(); - } -} diff --git a/src/test/resources/chrome.properties b/src/test/resources/chrome.properties deleted file mode 100644 index b4f7d89..0000000 --- a/src/test/resources/chrome.properties +++ /dev/null @@ -1,2 +0,0 @@ -#arguments=--ignore-certificate-errors --start-maximized --incognito -#enableVNC=true \ No newline at end of file diff --git a/src/test/resources/common.properties b/src/test/resources/common.properties deleted file mode 100644 index c31a28a..0000000 --- a/src/test/resources/common.properties +++ /dev/null @@ -1 +0,0 @@ -arguments=--headless diff --git a/src/test/resources/general.xml b/src/test/resources/general.xml deleted file mode 100644 index 6acc4dd..0000000 --- a/src/test/resources/general.xml +++ /dev/null @@ -1,13 +0,0 @@ - - - - - - - - - - - - - \ No newline at end of file diff --git a/src/test/resources/test.properties b/src/test/resources/test.properties deleted file mode 100644 index 0e76f23..0000000 --- a/src/test/resources/test.properties +++ /dev/null @@ -1,33 +0,0 @@ -driver=${driver} -driver.remote.url=${driver.remote.url} -timeout.wait.element=10 -domain=${domain} -page.check.after.open=NONE -# NEW_PAGE | EVERY_PAGE -#element.search.strategy=strict | soft | visible, multiple | any, single -element.search.strategy=strict -smart.locator=#%s -#smart.locator.to.name=kebab-case | camelCase | snake_case | PascalCase | UPPER_SNAKE_CASE -log.level=${log.level} -log.info.details=element -#text.type=SMART_TEXT | TEXT | VALUE | INNER | LABEL -#set.text.type=SET_TEXT | SEND_KEYS | CLEAR_SEND_KEYS -#assert.type=strict | soft - -#page.load.strategy=normal -#browser.size=MAXIMIZE | 1024x762 -#browser.kill=afterAndBefore | after | before -#drivers.folder=C:\\Selenium -#log.message.format=short | full -#demo.mode=false | true -#demo.delay=2 -#remote.type=sauce | browserstack -#driver.remote.url=http://localhost:4444/wd/hub -#headless=true | false -screenshot.strategy=on failure -#element.highlight=off | on failure | on assert | on action | flow -#screenshot.strategy=off | on failure | on assert | new page | flow -#allure.steps=true -#html.code.strategy=off | on failure | on assert | new page -#requests.strategy=off | on failure | on assert | new page -#screenshot.tool=selenium | robot \ No newline at end of file From 8caf94543837959f458692383a435ea53797257a Mon Sep 17 00:00:00 2001 From: Aleksandr_Vorobev Date: Wed, 27 Dec 2023 02:05:30 +0300 Subject: [PATCH 03/28] jdn-template-selenide update git ignore --- .gitignore | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/.gitignore b/.gitignore index 524f096..45d878c 100644 --- a/.gitignore +++ b/.gitignore @@ -22,3 +22,12 @@ # virtual machine crash logs, see http://www.java.com/en/download/help/error_hotspot.xml hs_err_pid* replay_pid* + +# Idea files +*.iml +.idea/ +target/ + +# Allure files +.allure/ +allure-results/ \ No newline at end of file From 2ca5da0012155772e430b2316a3c6d14583336a5 Mon Sep 17 00:00:00 2001 From: Aleksandr_Vorobev Date: Wed, 27 Dec 2023 02:10:40 +0300 Subject: [PATCH 04/28] jdn-template-selenide fix comments --- src/main/java/site/MySite.java | 4 ---- src/main/java/site/pages/BasePage.java | 6 +++++- 2 files changed, 5 insertions(+), 5 deletions(-) diff --git a/src/main/java/site/MySite.java b/src/main/java/site/MySite.java index 6cfd6dd..6953558 100644 --- a/src/main/java/site/MySite.java +++ b/src/main/java/site/MySite.java @@ -7,8 +7,4 @@ public class MySite { public static FirstPage firstPage; - - //endregion - - // ADD SITE PAGES WITH URLS } diff --git a/src/main/java/site/pages/BasePage.java b/src/main/java/site/pages/BasePage.java index 060677e..99ee222 100644 --- a/src/main/java/site/pages/BasePage.java +++ b/src/main/java/site/pages/BasePage.java @@ -4,8 +4,12 @@ import static com.codeborne.selenide.Selenide.open; -// This is an example of Page Object definition. To be removed +// This is an example of Page Object definition. +// ADD PAGES CLASS WITH URLS AS PATH + public abstract class BasePage { + + protected String PATH; protected String TITLE; From 78a3ce389ac733a4d4f586d6aa924cc997c8ff8d Mon Sep 17 00:00:00 2001 From: Aleksandr_Vorobev Date: Wed, 3 Jan 2024 11:11:04 +0300 Subject: [PATCH 05/28] jdn-template-selenide complete --- src/main/java/site/MySite.java | 10 ------- src/main/java/site/pages/BasePage.java | 2 -- src/main/resources/selenide.properties | 25 ----------------- .../resources/{general.xml => testng.xml} | 4 +-- src/main/test/java/test/BaseTest.java | 5 ---- src/main/test/java/test/ExampleTests.java | 6 +++-- .../java/testng/RetryFailedTestCases.java | 27 +++++++++++++++++++ .../test/java/testng/RetryListenerClass.java | 19 +++++++++++++ 8 files changed, 51 insertions(+), 47 deletions(-) delete mode 100644 src/main/java/site/MySite.java delete mode 100644 src/main/resources/selenide.properties rename src/main/resources/{general.xml => testng.xml} (63%) create mode 100644 src/main/test/java/testng/RetryFailedTestCases.java create mode 100644 src/main/test/java/testng/RetryListenerClass.java diff --git a/src/main/java/site/MySite.java b/src/main/java/site/MySite.java deleted file mode 100644 index 6953558..0000000 --- a/src/main/java/site/MySite.java +++ /dev/null @@ -1,10 +0,0 @@ -package site; - -import com.codeborne.selenide.Configuration; -import site.pages.FirstPage; - -import static com.codeborne.selenide.FileDownloadMode.FOLDER; - -public class MySite { - public static FirstPage firstPage; -} diff --git a/src/main/java/site/pages/BasePage.java b/src/main/java/site/pages/BasePage.java index 99ee222..11674a3 100644 --- a/src/main/java/site/pages/BasePage.java +++ b/src/main/java/site/pages/BasePage.java @@ -2,8 +2,6 @@ import com.codeborne.selenide.Selenide; -import static com.codeborne.selenide.Selenide.open; - // This is an example of Page Object definition. // ADD PAGES CLASS WITH URLS AS PATH diff --git a/src/main/resources/selenide.properties b/src/main/resources/selenide.properties deleted file mode 100644 index 36507fd..0000000 --- a/src/main/resources/selenide.properties +++ /dev/null @@ -1,25 +0,0 @@ -# selenide.properties - -# Base URL -baseUrl=https://www.example.com - -# Browser type -browser=chrome - -# Page load timeout -timeout=20000 - -# Headless mode -headless=false - -# Browser size -browserSize=1920x1200 - -# Start maximized -startMaximized=true - -# Enable screenshots -screenshots=true - -# File download folder -fileDownload=FOLDER diff --git a/src/main/resources/general.xml b/src/main/resources/testng.xml similarity index 63% rename from src/main/resources/general.xml rename to src/main/resources/testng.xml index 478cc31..20fc21a 100644 --- a/src/main/resources/general.xml +++ b/src/main/resources/testng.xml @@ -10,8 +10,6 @@ - - - + \ No newline at end of file diff --git a/src/main/test/java/test/BaseTest.java b/src/main/test/java/test/BaseTest.java index 08114f5..23a8b8f 100644 --- a/src/main/test/java/test/BaseTest.java +++ b/src/main/test/java/test/BaseTest.java @@ -5,8 +5,6 @@ import org.testng.annotations.AfterSuite; import org.testng.annotations.BeforeSuite; import org.testng.annotations.Listeners; -import site.MySite; -import site.pages.FirstPage; import static com.codeborne.selenide.FileDownloadMode.FOLDER; @@ -16,14 +14,11 @@ public interface BaseTest { public static void setUp() { Configuration.baseUrl = "https://www.example.com"; Configuration.browser = "chrome"; // You can also use "firefox", "edge", etc. - - // Other common configurations... Configuration.pageLoadTimeout = 20000; Configuration.headless = false; Configuration.browserSize = "1920x1200"; Configuration.screenshots = true; Configuration.fileDownload = FOLDER; - MySite.firstPage = new FirstPage(); } @AfterSuite diff --git a/src/main/test/java/test/ExampleTests.java b/src/main/test/java/test/ExampleTests.java index 0e4c8bf..9619cf3 100644 --- a/src/main/test/java/test/ExampleTests.java +++ b/src/main/test/java/test/ExampleTests.java @@ -1,11 +1,13 @@ package test; import org.testng.annotations.Test; -import site.MySite; +import site.pages.FirstPage; public class ExampleTests implements BaseTest { + FirstPage firstPage = new FirstPage(); + @Test public void openPageTest() { - MySite.firstPage.openPage(); + firstPage.openPage(); } } diff --git a/src/main/test/java/testng/RetryFailedTestCases.java b/src/main/test/java/testng/RetryFailedTestCases.java new file mode 100644 index 0000000..1763da8 --- /dev/null +++ b/src/main/test/java/testng/RetryFailedTestCases.java @@ -0,0 +1,27 @@ +package testng; + +import lombok.extern.log4j.Log4j2; +import org.testng.IRetryAnalyzer; +import org.testng.ITestResult; + + +@Log4j2 +public class RetryFailedTestCases implements IRetryAnalyzer { + private int retryCnt = 0; + + // This method will be called everytime a test fails. + // It will return TRUE if a test fails and need to be retried, else it returns FALSE + public boolean retry(ITestResult result) { + // You could mention maxRetryCnt (Maximiun Retry Count) as per your requirement. + // Here I took 2, If any failed testcases then it runs two times + int maxRetryCnt = 1; + if (retryCnt < maxRetryCnt) { + log.info("Retrying " + result.getName() + " again and the count is " + (retryCnt+1)); + retryCnt++; + return true; + } + return false; + } + +} + diff --git a/src/main/test/java/testng/RetryListenerClass.java b/src/main/test/java/testng/RetryListenerClass.java new file mode 100644 index 0000000..7fd6073 --- /dev/null +++ b/src/main/test/java/testng/RetryListenerClass.java @@ -0,0 +1,19 @@ +package testng; + +import org.testng.IAnnotationTransformer; +import org.testng.annotations.ITestAnnotation; + +import java.lang.reflect.Constructor; +import java.lang.reflect.Method; + +public class RetryListenerClass implements IAnnotationTransformer { + + @Override + public void transform(ITestAnnotation testannotation, Class testClass, Constructor testConstructor, Method testMethod) { + Class retry = testannotation.getRetryAnalyzerClass(); + if (retry == null) { + testannotation.setRetryAnalyzer(RetryFailedTestCases.class); + } + + } +} From 385a65dff4313070456ff758303f054c9130ba2f Mon Sep 17 00:00:00 2001 From: Aleksandr_Vorobev Date: Fri, 5 Jan 2024 13:47:53 +0300 Subject: [PATCH 06/28] jdn-template-selenide upd test --- src/main/java/site/pages/{FirstPage.java => HomePage.java} | 6 +++--- src/main/resources/testng.xml | 1 + src/main/test/java/test/ExampleTests.java | 7 ++++--- 3 files changed, 8 insertions(+), 6 deletions(-) rename src/main/java/site/pages/{FirstPage.java => HomePage.java} (70%) diff --git a/src/main/java/site/pages/FirstPage.java b/src/main/java/site/pages/HomePage.java similarity index 70% rename from src/main/java/site/pages/FirstPage.java rename to src/main/java/site/pages/HomePage.java index 710d536..87d6e1c 100644 --- a/src/main/java/site/pages/FirstPage.java +++ b/src/main/java/site/pages/HomePage.java @@ -5,12 +5,12 @@ import static com.codeborne.selenide.Selenide.$; // This is an example of Page Object definition. To be removed -public class FirstPage extends BasePage { +public class HomePage extends BasePage { private static final String PATH = "/"; private static final String TITLE = "/"; - public static SelenideElement testButton = $("button"); + public SelenideElement moreInformationLink = $("p > a"); - public FirstPage() { + public HomePage() { super(TITLE, PATH); } } diff --git a/src/main/resources/testng.xml b/src/main/resources/testng.xml index 20fc21a..800d10d 100644 --- a/src/main/resources/testng.xml +++ b/src/main/resources/testng.xml @@ -11,5 +11,6 @@ + \ No newline at end of file diff --git a/src/main/test/java/test/ExampleTests.java b/src/main/test/java/test/ExampleTests.java index 9619cf3..ee3390b 100644 --- a/src/main/test/java/test/ExampleTests.java +++ b/src/main/test/java/test/ExampleTests.java @@ -1,13 +1,14 @@ package test; import org.testng.annotations.Test; -import site.pages.FirstPage; +import site.pages.HomePage; public class ExampleTests implements BaseTest { - FirstPage firstPage = new FirstPage(); + HomePage homePage = new HomePage(); @Test public void openPageTest() { - firstPage.openPage(); + homePage.openPage(); + homePage.moreInformationLink.click(); } } From c52ca472c8dd934bf09056e102ca28fc41cbec68 Mon Sep 17 00:00:00 2001 From: Aleksandr_Vorobev Date: Fri, 5 Jan 2024 15:09:10 +0300 Subject: [PATCH 07/28] update listener --- README.md | 2 + pom.xml | 66 ++++++------------- src/main/java/site/pages/BasePage.java | 4 -- src/main/java/site/pages/HomePage.java | 1 - .../java/testng/RetryFailedTestCases.java | 27 -------- .../test/java/testng/RetryListenerClass.java | 19 ------ src/{main => }/test/java/test/BaseTest.java | 0 .../test/java/test/ExampleTests.java | 0 src/test/java/testng/RetryAnalyzer.java | 19 ++++++ src/test/java/testng/RetryTransformer.java | 15 +++++ src/{main => test}/resources/log4j2.xml | 0 src/{main => test}/resources/testng.xml | 5 +- 12 files changed, 57 insertions(+), 101 deletions(-) delete mode 100644 src/main/test/java/testng/RetryFailedTestCases.java delete mode 100644 src/main/test/java/testng/RetryListenerClass.java rename src/{main => }/test/java/test/BaseTest.java (100%) rename src/{main => }/test/java/test/ExampleTests.java (100%) create mode 100644 src/test/java/testng/RetryAnalyzer.java create mode 100644 src/test/java/testng/RetryTransformer.java rename src/{main => test}/resources/log4j2.xml (100%) rename src/{main => test}/resources/testng.xml (75%) diff --git a/README.md b/README.md index 22ec999..45e0216 100644 --- a/README.md +++ b/README.md @@ -1,2 +1,4 @@ # jdn-template-selenide Template project for JDN with Selenide + +Setup test configs in "src/test/java/test/BaseTest.java" \ No newline at end of file diff --git a/pom.xml b/pom.xml index c9399d2..0936568 100644 --- a/pom.xml +++ b/pom.xml @@ -14,8 +14,6 @@ 1.9.7 https://jdi-testing.github.io/jdi-light/ 7.8.0 - - 9.4.12.RC2 INFO @@ -32,20 +30,14 @@ --add-opens java.base/java.lang=ALL-UNNAMED - - - ci - - false - - - http://localhost:4444/wd/hub - INFO - - + + org.apache.commons + commons-configuration2 + 2.7 + org.apache.logging.log4j @@ -59,23 +51,6 @@ 7.0.4 compile - - - - - - - - - - - - - - - - - org.testng testng @@ -99,8 +74,12 @@ 7.8.0 compile + + io.qameta.allure + allure-testng + 2.13.6 + - @@ -117,16 +96,19 @@ maven-surefire-plugin 2.22.2 - - - - src/test/resources/general.xml + src/test/resources/testng.xml ${aspectj.args} -javaagent:"${settings.localRepository}/org/aspectj/aspectjweaver/${aspectj.version}/aspectjweaver-${aspectj.version}.jar" + + + listener + io.qameta.allure.testng.AllureTestNg + + @@ -136,25 +118,15 @@ - - - - - - - - - - ${project.basedir}/src/main/resources + src/test/resources - src/main/resources + src/test/resources true - diff --git a/src/main/java/site/pages/BasePage.java b/src/main/java/site/pages/BasePage.java index 11674a3..9fd1c00 100644 --- a/src/main/java/site/pages/BasePage.java +++ b/src/main/java/site/pages/BasePage.java @@ -1,10 +1,6 @@ package site.pages; import com.codeborne.selenide.Selenide; - -// This is an example of Page Object definition. -// ADD PAGES CLASS WITH URLS AS PATH - public abstract class BasePage { diff --git a/src/main/java/site/pages/HomePage.java b/src/main/java/site/pages/HomePage.java index 87d6e1c..5ba48a1 100644 --- a/src/main/java/site/pages/HomePage.java +++ b/src/main/java/site/pages/HomePage.java @@ -4,7 +4,6 @@ import static com.codeborne.selenide.Selenide.$; -// This is an example of Page Object definition. To be removed public class HomePage extends BasePage { private static final String PATH = "/"; private static final String TITLE = "/"; diff --git a/src/main/test/java/testng/RetryFailedTestCases.java b/src/main/test/java/testng/RetryFailedTestCases.java deleted file mode 100644 index 1763da8..0000000 --- a/src/main/test/java/testng/RetryFailedTestCases.java +++ /dev/null @@ -1,27 +0,0 @@ -package testng; - -import lombok.extern.log4j.Log4j2; -import org.testng.IRetryAnalyzer; -import org.testng.ITestResult; - - -@Log4j2 -public class RetryFailedTestCases implements IRetryAnalyzer { - private int retryCnt = 0; - - // This method will be called everytime a test fails. - // It will return TRUE if a test fails and need to be retried, else it returns FALSE - public boolean retry(ITestResult result) { - // You could mention maxRetryCnt (Maximiun Retry Count) as per your requirement. - // Here I took 2, If any failed testcases then it runs two times - int maxRetryCnt = 1; - if (retryCnt < maxRetryCnt) { - log.info("Retrying " + result.getName() + " again and the count is " + (retryCnt+1)); - retryCnt++; - return true; - } - return false; - } - -} - diff --git a/src/main/test/java/testng/RetryListenerClass.java b/src/main/test/java/testng/RetryListenerClass.java deleted file mode 100644 index 7fd6073..0000000 --- a/src/main/test/java/testng/RetryListenerClass.java +++ /dev/null @@ -1,19 +0,0 @@ -package testng; - -import org.testng.IAnnotationTransformer; -import org.testng.annotations.ITestAnnotation; - -import java.lang.reflect.Constructor; -import java.lang.reflect.Method; - -public class RetryListenerClass implements IAnnotationTransformer { - - @Override - public void transform(ITestAnnotation testannotation, Class testClass, Constructor testConstructor, Method testMethod) { - Class retry = testannotation.getRetryAnalyzerClass(); - if (retry == null) { - testannotation.setRetryAnalyzer(RetryFailedTestCases.class); - } - - } -} diff --git a/src/main/test/java/test/BaseTest.java b/src/test/java/test/BaseTest.java similarity index 100% rename from src/main/test/java/test/BaseTest.java rename to src/test/java/test/BaseTest.java diff --git a/src/main/test/java/test/ExampleTests.java b/src/test/java/test/ExampleTests.java similarity index 100% rename from src/main/test/java/test/ExampleTests.java rename to src/test/java/test/ExampleTests.java diff --git a/src/test/java/testng/RetryAnalyzer.java b/src/test/java/testng/RetryAnalyzer.java new file mode 100644 index 0000000..494a042 --- /dev/null +++ b/src/test/java/testng/RetryAnalyzer.java @@ -0,0 +1,19 @@ +package testng; + +import org.testng.IRetryAnalyzer; +import org.testng.ITestResult; + +public class RetryAnalyzer implements IRetryAnalyzer { + + private int retryCount = 0; + private static final int MAX_RETRY_COUNT = 3; + + @Override + public boolean retry(ITestResult iTestResult) { + if (retryCount < MAX_RETRY_COUNT) { + retryCount++; + return true; // Retry the test + } + return false; // No retry + } +} diff --git a/src/test/java/testng/RetryTransformer.java b/src/test/java/testng/RetryTransformer.java new file mode 100644 index 0000000..a0efd14 --- /dev/null +++ b/src/test/java/testng/RetryTransformer.java @@ -0,0 +1,15 @@ +package testng; + +import java.lang.reflect.Constructor; +import java.lang.reflect.Method; + +import org.testng.IAnnotationTransformer; +import org.testng.annotations.ITestAnnotation; + +public class RetryTransformer implements IAnnotationTransformer { + + @Override + public void transform(ITestAnnotation iTestAnnotation, Class aClass, Constructor constructor, Method method) { + iTestAnnotation.setRetryAnalyzer(RetryAnalyzer.class); + } +} diff --git a/src/main/resources/log4j2.xml b/src/test/resources/log4j2.xml similarity index 100% rename from src/main/resources/log4j2.xml rename to src/test/resources/log4j2.xml diff --git a/src/main/resources/testng.xml b/src/test/resources/testng.xml similarity index 75% rename from src/main/resources/testng.xml rename to src/test/resources/testng.xml index 800d10d..8f59f75 100644 --- a/src/main/resources/testng.xml +++ b/src/test/resources/testng.xml @@ -7,10 +7,9 @@ - - - + + \ No newline at end of file From fb57bb01caad23007c0fa622aed3fb73521af230 Mon Sep 17 00:00:00 2001 From: Aleksandr_Vorobev Date: Fri, 5 Jan 2024 15:36:16 +0300 Subject: [PATCH 08/28] update pom file --- pom.xml | 27 ++++++++++++++++++++++++--- src/test/java/test/BaseTest.java | 6 +++++- src/test/java/test/ExampleTests.java | 2 ++ 3 files changed, 31 insertions(+), 4 deletions(-) diff --git a/pom.xml b/pom.xml index 0936568..aed4ddb 100644 --- a/pom.xml +++ b/pom.xml @@ -17,7 +17,6 @@ 9.4.12.RC2 INFO - @@ -79,16 +78,35 @@ allure-testng 2.13.6 + + io.qameta.allure + allure-selenide + 2.13.6 + + + io.qameta.allure + allure-maven + 2.12.0 + + 2.13.6 + + + allure.results.directory + target + + + + org.apache.maven.plugins maven-compiler-plugin 3.8.1 - 16 - 16 + 11 + 11 @@ -96,6 +114,9 @@ maven-surefire-plugin 2.22.2 + + ${project.build.directory}/allure-results + src/test/resources/testng.xml diff --git a/src/test/java/test/BaseTest.java b/src/test/java/test/BaseTest.java index 23a8b8f..e177652 100644 --- a/src/test/java/test/BaseTest.java +++ b/src/test/java/test/BaseTest.java @@ -2,6 +2,8 @@ import com.codeborne.selenide.Configuration; import com.codeborne.selenide.Selenide; +import com.codeborne.selenide.logevents.SelenideLogger; +import io.qameta.allure.selenide.AllureSelenide; import org.testng.annotations.AfterSuite; import org.testng.annotations.BeforeSuite; import org.testng.annotations.Listeners; @@ -12,6 +14,8 @@ public interface BaseTest { @BeforeSuite public static void setUp() { + SelenideLogger.addListener("AllureSelenide", new AllureSelenide().screenshots(true) + .savePageSource(false)); Configuration.baseUrl = "https://www.example.com"; Configuration.browser = "chrome"; // You can also use "firefox", "edge", etc. Configuration.pageLoadTimeout = 20000; @@ -23,7 +27,7 @@ public static void setUp() { @AfterSuite public static void tearDown() { - // Close all open browsers + SelenideLogger.removeListener("AllureSelenide"); Selenide.closeWebDriver(); } } diff --git a/src/test/java/test/ExampleTests.java b/src/test/java/test/ExampleTests.java index ee3390b..3e934ac 100644 --- a/src/test/java/test/ExampleTests.java +++ b/src/test/java/test/ExampleTests.java @@ -1,5 +1,6 @@ package test; +import io.qameta.allure.Description; import org.testng.annotations.Test; import site.pages.HomePage; @@ -7,6 +8,7 @@ public class ExampleTests implements BaseTest { HomePage homePage = new HomePage(); @Test + @Description("Example Test") public void openPageTest() { homePage.openPage(); homePage.moreInformationLink.click(); From 9bd049f18a19c1a4e0b33a534fc48620c3bf402b Mon Sep 17 00:00:00 2001 From: Aleksandr_Vorobev Date: Fri, 5 Jan 2024 15:37:59 +0300 Subject: [PATCH 09/28] set element name --- src/main/java/site/pages/HomePage.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/main/java/site/pages/HomePage.java b/src/main/java/site/pages/HomePage.java index 5ba48a1..18739c8 100644 --- a/src/main/java/site/pages/HomePage.java +++ b/src/main/java/site/pages/HomePage.java @@ -7,7 +7,7 @@ public class HomePage extends BasePage { private static final String PATH = "/"; private static final String TITLE = "/"; - public SelenideElement moreInformationLink = $("p > a"); + public SelenideElement moreInformationLink = $("p > a").as("more information link"); public HomePage() { super(TITLE, PATH); From 6aab38c6a371f02ecbd4dc75b1a623e7a6868342 Mon Sep 17 00:00:00 2001 From: Aleksandr_Vorobev Date: Mon, 8 Jan 2024 15:53:20 +0300 Subject: [PATCH 10/28] fix after review --- pom.xml | 28 ++-------------------------- 1 file changed, 2 insertions(+), 26 deletions(-) diff --git a/pom.xml b/pom.xml index aed4ddb..67b4dcb 100644 --- a/pom.xml +++ b/pom.xml @@ -9,14 +9,7 @@ Template: Selenide TestNG Testing project - chrome - UTF-8 - 1.9.7 - https://jdi-testing.github.io/jdi-light/ 7.8.0 - 9.4.12.RC2 - - INFO @@ -67,12 +60,6 @@ selenide-core 7.0.4 - - org.testng - testng - 7.8.0 - compile - io.qameta.allure allure-testng @@ -105,8 +92,8 @@ maven-compiler-plugin 3.8.1 - 11 - 11 + 8 + 8 @@ -120,10 +107,6 @@ src/test/resources/testng.xml - - ${aspectj.args} - -javaagent:"${settings.localRepository}/org/aspectj/aspectjweaver/${aspectj.version}/aspectjweaver-${aspectj.version}.jar" - listener @@ -131,13 +114,6 @@ - - - org.aspectj - aspectjweaver - ${aspectj.version} - - From 4ae241a3867a9202efb427500e52d54264df1b33 Mon Sep 17 00:00:00 2001 From: Aleksandr_Vorobev Date: Tue, 9 Jan 2024 15:49:26 +0300 Subject: [PATCH 11/28] remove extra profiles --- pom.xml | 13 ------------- 1 file changed, 13 deletions(-) diff --git a/pom.xml b/pom.xml index 67b4dcb..571d8d1 100644 --- a/pom.xml +++ b/pom.xml @@ -11,19 +11,6 @@ 7.8.0 - - - - jdk16 - - [16, 20] - - - --add-opens java.base/java.lang=ALL-UNNAMED - - - - org.apache.commons From 21d66b60c2f8efe7ab3fd7bb65e25a4ab05c8bd1 Mon Sep 17 00:00:00 2001 From: Aleksandr_Vorobev Date: Tue, 9 Jan 2024 15:57:03 +0300 Subject: [PATCH 12/28] downgrade selenide to support java 11 --- pom.xml | 2 +- src/test/java/test/ExampleTests.java | 4 +--- 2 files changed, 2 insertions(+), 4 deletions(-) diff --git a/pom.xml b/pom.xml index 571d8d1..005fdac 100644 --- a/pom.xml +++ b/pom.xml @@ -27,7 +27,7 @@ com.codeborne selenide - 7.0.4 + 5.25.1 compile diff --git a/src/test/java/test/ExampleTests.java b/src/test/java/test/ExampleTests.java index 3e934ac..f86d994 100644 --- a/src/test/java/test/ExampleTests.java +++ b/src/test/java/test/ExampleTests.java @@ -1,14 +1,12 @@ package test; -import io.qameta.allure.Description; import org.testng.annotations.Test; import site.pages.HomePage; public class ExampleTests implements BaseTest { HomePage homePage = new HomePage(); - @Test - @Description("Example Test") + @Test(description = "Example test") public void openPageTest() { homePage.openPage(); homePage.moreInformationLink.click(); From 077d1b2aa06b12b067dd3c530c9073711a1a463d Mon Sep 17 00:00:00 2001 From: Aleksandr_Vorobev Date: Tue, 9 Jan 2024 16:05:38 +0300 Subject: [PATCH 13/28] update pom.xml --- pom.xml | 37 ++++++++++++++++++++++++++----------- 1 file changed, 26 insertions(+), 11 deletions(-) diff --git a/pom.xml b/pom.xml index 005fdac..37acedf 100644 --- a/pom.xml +++ b/pom.xml @@ -10,52 +10,67 @@ 7.8.0 + 2.7 + 2.22.0 + 5.25.1 + 1.18.22 + 7.0.4 + 2.13.6 + 2.12.0 + 3.8.1 + 2.22.2 + + org.apache.commons commons-configuration2 - 2.7 + ${commons.config.version} org.apache.logging.log4j log4j-core - 2.22.0 + ${log4j.core.version} com.codeborne selenide - 5.25.1 + ${selenide.version} compile + org.testng testng ${testng.version} test + org.projectlombok lombok - 1.18.22 + ${lombok.version} test + com.codeborne selenide-core - 7.0.4 + ${selenide.core.version} io.qameta.allure allure-testng - 2.13.6 + ${allure.version} + io.qameta.allure allure-selenide - 2.13.6 + ${allure.version} @@ -63,9 +78,9 @@ io.qameta.allure allure-maven - 2.12.0 + ${allure.maven.version} - 2.13.6 + ${allure.version} allure.results.directory @@ -77,7 +92,7 @@ org.apache.maven.plugins maven-compiler-plugin - 3.8.1 + ${maven.compiler.plugin.version} 8 8 @@ -86,7 +101,7 @@ org.apache.maven.plugins maven-surefire-plugin - 2.22.2 + ${maven.surefire.plugin.version} ${project.build.directory}/allure-results From 6624efee4fcb06d837e81cf27cfdce844c8312cc Mon Sep 17 00:00:00 2001 From: Aleksandr_Vorobev Date: Tue, 9 Jan 2024 16:15:46 +0300 Subject: [PATCH 14/28] update pom.xml --- pom.xml | 1 + 1 file changed, 1 insertion(+) diff --git a/pom.xml b/pom.xml index 37acedf..4655ce7 100644 --- a/pom.xml +++ b/pom.xml @@ -73,6 +73,7 @@ ${allure.version} + From 4826bdf87ad5efeacd059a24e2b509412e8a35c4 Mon Sep 17 00:00:00 2001 From: Aleksandr_Vorobev Date: Wed, 10 Jan 2024 16:00:29 +0300 Subject: [PATCH 15/28] update README.md --- README.md | 25 ++++++++++++++++++++++--- 1 file changed, 22 insertions(+), 3 deletions(-) diff --git a/README.md b/README.md index 45e0216..e02ab98 100644 --- a/README.md +++ b/README.md @@ -1,4 +1,23 @@ -# jdn-template-selenide -Template project for JDN with Selenide +# Selenium Testng empty template -Setup test configs in "src/test/java/test/BaseTest.java" \ No newline at end of file +Empty template for Test Automation project with Selenide + +# Instruction: + +1. Download template and unpack in appropriate folder + +2. Open project in IDE (for example IntelliJIdea) + +3. Reporting: Allure is enabled, after running tests just run **allure:serve** in maven plugins (allure should be + installed locally) + +4. Parameters that can be changed: + +- File src/test/java/test/BaseTest.java There are settings to define: +- baseUrl - base url of your site under tests + browser - chrome/edge/firefox etc. + pageLoadTimeout - timeout to wait page load + headless - to run tests in headless mode, so if you want to hide browser set true + +5. TestNg Retry and before after listeners: You can also modify rules of retry tests (now it is 1 retry for each test) + and actions before/after all tests (now it prints test name and result) in **testng** folder From df163683982675e386cea97b3eccbc90048eb362 Mon Sep 17 00:00:00 2001 From: Aleksandr_Vorobev Date: Wed, 10 Jan 2024 16:02:24 +0300 Subject: [PATCH 16/28] update README.md --- README.md | 9 ++++----- 1 file changed, 4 insertions(+), 5 deletions(-) diff --git a/README.md b/README.md index e02ab98..42a0365 100644 --- a/README.md +++ b/README.md @@ -11,13 +11,12 @@ Empty template for Test Automation project with Selenide 3. Reporting: Allure is enabled, after running tests just run **allure:serve** in maven plugins (allure should be installed locally) -4. Parameters that can be changed: +4. Parameters that can be changed placed in src/test/java/test/BaseTest.java -- File src/test/java/test/BaseTest.java There are settings to define: - baseUrl - base url of your site under tests - browser - chrome/edge/firefox etc. - pageLoadTimeout - timeout to wait page load - headless - to run tests in headless mode, so if you want to hide browser set true +- browser - chrome/edge/firefox etc. +- pageLoadTimeout - timeout to wait page load +- headless - to run tests in headless mode, so if you want to hide browser set true 5. TestNg Retry and before after listeners: You can also modify rules of retry tests (now it is 1 retry for each test) and actions before/after all tests (now it prints test name and result) in **testng** folder From 27a28d9ecb33d209fdd06a172dc70c39f560cc56 Mon Sep 17 00:00:00 2001 From: Aleksandr_Vorobev Date: Wed, 10 Jan 2024 16:04:04 +0300 Subject: [PATCH 17/28] refactor structure --- src/main/java/{site/pages => page}/BasePage.java | 2 +- src/main/java/{site/pages => page}/HomePage.java | 2 +- src/test/java/test/ExampleTests.java | 2 +- 3 files changed, 3 insertions(+), 3 deletions(-) rename src/main/java/{site/pages => page}/BasePage.java (94%) rename src/main/java/{site/pages => page}/HomePage.java (94%) diff --git a/src/main/java/site/pages/BasePage.java b/src/main/java/page/BasePage.java similarity index 94% rename from src/main/java/site/pages/BasePage.java rename to src/main/java/page/BasePage.java index 9fd1c00..1dadc57 100644 --- a/src/main/java/site/pages/BasePage.java +++ b/src/main/java/page/BasePage.java @@ -1,4 +1,4 @@ -package site.pages; +package page; import com.codeborne.selenide.Selenide; public abstract class BasePage { diff --git a/src/main/java/site/pages/HomePage.java b/src/main/java/page/HomePage.java similarity index 94% rename from src/main/java/site/pages/HomePage.java rename to src/main/java/page/HomePage.java index 18739c8..e1c8784 100644 --- a/src/main/java/site/pages/HomePage.java +++ b/src/main/java/page/HomePage.java @@ -1,4 +1,4 @@ -package site.pages; +package page; import com.codeborne.selenide.SelenideElement; diff --git a/src/test/java/test/ExampleTests.java b/src/test/java/test/ExampleTests.java index f86d994..afb01c2 100644 --- a/src/test/java/test/ExampleTests.java +++ b/src/test/java/test/ExampleTests.java @@ -1,7 +1,7 @@ package test; import org.testng.annotations.Test; -import site.pages.HomePage; +import page.HomePage; public class ExampleTests implements BaseTest { HomePage homePage = new HomePage(); From 038bbfe90e7a0945a0f97d7e5d3b783710e80c6b Mon Sep 17 00:00:00 2001 From: Aleksandr_Vorobev Date: Wed, 10 Jan 2024 16:09:39 +0300 Subject: [PATCH 18/28] refactor structure --- src/main/java/page/BasePage.java | 18 ------------------ src/main/java/pages/BasePage.java | 18 ++++++++++++++++++ src/main/java/{page => pages}/HomePage.java | 2 +- src/test/java/test/ExampleTests.java | 4 ++-- 4 files changed, 21 insertions(+), 21 deletions(-) delete mode 100644 src/main/java/page/BasePage.java create mode 100644 src/main/java/pages/BasePage.java rename src/main/java/{page => pages}/HomePage.java (96%) diff --git a/src/main/java/page/BasePage.java b/src/main/java/page/BasePage.java deleted file mode 100644 index 1dadc57..0000000 --- a/src/main/java/page/BasePage.java +++ /dev/null @@ -1,18 +0,0 @@ -package page; - -import com.codeborne.selenide.Selenide; -public abstract class BasePage { - - - protected String PATH; - protected String TITLE; - - public BasePage(final String title, final String path) { - this.PATH = path; - this.TITLE = title; - } - - public void openPage() { - Selenide.open(this.PATH); - } -} diff --git a/src/main/java/pages/BasePage.java b/src/main/java/pages/BasePage.java new file mode 100644 index 0000000..252595c --- /dev/null +++ b/src/main/java/pages/BasePage.java @@ -0,0 +1,18 @@ +package pages; + +import com.codeborne.selenide.Selenide; +public abstract class BasePage { + + + protected String path; + protected String title; + + protected BasePage(final String title, final String path) { + this.path = path; + this.title = title; + } + + public void openPage() { + Selenide.open(this.path); + } +} diff --git a/src/main/java/page/HomePage.java b/src/main/java/pages/HomePage.java similarity index 96% rename from src/main/java/page/HomePage.java rename to src/main/java/pages/HomePage.java index e1c8784..fae09ea 100644 --- a/src/main/java/page/HomePage.java +++ b/src/main/java/pages/HomePage.java @@ -1,4 +1,4 @@ -package page; +package pages; import com.codeborne.selenide.SelenideElement; diff --git a/src/test/java/test/ExampleTests.java b/src/test/java/test/ExampleTests.java index afb01c2..b224c8a 100644 --- a/src/test/java/test/ExampleTests.java +++ b/src/test/java/test/ExampleTests.java @@ -1,7 +1,7 @@ package test; import org.testng.annotations.Test; -import page.HomePage; +import pages.HomePage; public class ExampleTests implements BaseTest { HomePage homePage = new HomePage(); @@ -11,4 +11,4 @@ public void openPageTest() { homePage.openPage(); homePage.moreInformationLink.click(); } -} +} \ No newline at end of file From 2f32ac670457c5c0b7a867fd9557c71983d66e37 Mon Sep 17 00:00:00 2001 From: Aleksandr_Vorobev Date: Wed, 10 Jan 2024 16:12:24 +0300 Subject: [PATCH 19/28] update README.md --- README.md | 2 ++ 1 file changed, 2 insertions(+) diff --git a/README.md b/README.md index 42a0365..8332e9e 100644 --- a/README.md +++ b/README.md @@ -20,3 +20,5 @@ Empty template for Test Automation project with Selenide 5. TestNg Retry and before after listeners: You can also modify rules of retry tests (now it is 1 retry for each test) and actions before/after all tests (now it prints test name and result) in **testng** folder + +6. pages generated by JDN should be places in src/main/java/pages package From 5c74c4e4cb446bc62f0be1c06b75cb3829fe82ee Mon Sep 17 00:00:00 2001 From: Aleksandr_Vorobev Date: Wed, 10 Jan 2024 16:14:55 +0300 Subject: [PATCH 20/28] update README.md --- README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/README.md b/README.md index 8332e9e..f3d8adc 100644 --- a/README.md +++ b/README.md @@ -1,4 +1,4 @@ -# Selenium Testng empty template +# Selenide Testng empty template Empty template for Test Automation project with Selenide From 0a1f2d859519e609ea6dd03e323637562fef9b86 Mon Sep 17 00:00:00 2001 From: Aleksandr_Vorobev Date: Wed, 10 Jan 2024 16:26:15 +0300 Subject: [PATCH 21/28] update README.md --- README.md | 3 +++ 1 file changed, 3 insertions(+) diff --git a/README.md b/README.md index f3d8adc..592c457 100644 --- a/README.md +++ b/README.md @@ -22,3 +22,6 @@ Empty template for Test Automation project with Selenide and actions before/after all tests (now it prints test name and result) in **testng** folder 6. pages generated by JDN should be places in src/main/java/pages package + +7. Each page object class must be inherited from BasePage, including one of the mandatory paremeters is PATH describing + the URI of the page e.g. in http://example.com/login PATH = "/login". From 5775736d5c403c23e777b6246bf813e3d39feddc Mon Sep 17 00:00:00 2001 From: Aleksandr_Vorobev Date: Tue, 16 Jan 2024 11:40:17 +0300 Subject: [PATCH 22/28] update encoding --- src/test/resources/testng.xml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/test/resources/testng.xml b/src/test/resources/testng.xml index 8f59f75..9a7007d 100644 --- a/src/test/resources/testng.xml +++ b/src/test/resources/testng.xml @@ -1,4 +1,4 @@ - + From 1df5b48a50855da93a8f8cf811f857da9b3c1e39 Mon Sep 17 00:00:00 2001 From: Aleksandr_Vorobev Date: Thu, 18 Jan 2024 13:30:34 +0300 Subject: [PATCH 23/28] update encoding --- src/test/resources/log4j2.xml | 113 +++++++++++++++++----------------- 1 file changed, 56 insertions(+), 57 deletions(-) diff --git a/src/test/resources/log4j2.xml b/src/test/resources/log4j2.xml index 6b7aec5..fb1a146 100644 --- a/src/test/resources/log4j2.xml +++ b/src/test/resources/log4j2.xml @@ -1,61 +1,60 @@ - - jdiEvents - ./target/.logs - - - - - - - - - ${baseDir}/${logFileName}_%d{yyyy-MM-dd__HH-mm}_%i.log - - %d{HH:mm:ss} [%t] %-5level %logger{6} - %msg%n - - - - - - - - - - - false - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - + + jdiEvents + ./target/.logs + + + + + + + + + ${baseDir}/${logFileName}_%d{yyyy-MM-dd__HH-mm}_%i.log + + %d{HH:mm:ss} [%t] %-5level %logger{6} - %msg%n + + + + + + + + + + + false + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + \ No newline at end of file From d6fdd186b7f8341831e5058dfb21416b38e1bded Mon Sep 17 00:00:00 2001 From: Aleksandr_Vorobev Date: Thu, 18 Jan 2024 13:46:03 +0300 Subject: [PATCH 24/28] add github actions --- .github/workflows/build.yml | 85 +++++++++++++++++++++++++++++++++++++ 1 file changed, 85 insertions(+) create mode 100644 .github/workflows/build.yml diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml new file mode 100644 index 0000000..fc2d0ea --- /dev/null +++ b/.github/workflows/build.yml @@ -0,0 +1,85 @@ +name: Run tests +env: + ALLURE_VERSION: "2.10.0" + +on: + push: + branches: + - main + + pull_request: + branches: + - main + release: + types: # This configuration does not affect the page_build event above + - created + +jobs: + build: + name: Tests on JDK + runs-on: ubuntu-latest + strategy: + fail-fast: false + matrix: + java: [ 11, 17 ] + + steps: + - uses: actions/checkout@v3 + - name: Set up JDK ${{ matrix.java }} + uses: actions/setup-java@v3 + with: + java-version: ${{ matrix.java }} + java-package: jdk + distribution: 'temurin' + cache: 'maven' + + - name: Build with Maven + id: build + run: mvn clean install -DskipTests -ntp + + - name: Start Selenoid + uses: Xotabu4/selenoid-github-action@v2 + id: start-selenoid + + - name: Check Selenoid has been started + run: curl http://localhost:4444/status + + - name: Tests + id: functests + timeout-minutes: 10 + continue-on-error: true + run: mvn test -ntp + + - name: Get Allure history + uses: actions/checkout@v3 + id: allure-setup + continue-on-error: true + with: + ref: gh-pages + path: gh-pages + + - name: Generate Allure report + uses: simple-elf/allure-report-action@master + with: + allure_results: target/allure-results + allure_report: target/allure-report + allure_history: allure-history + + - name: Upload Allure report + uses: actions/upload-artifact@master + with: + name: Allure report + path: target/allure-report + + - name: Deploy Allure report to Github Pages + uses: peaceiris/actions-gh-pages@v2 + env: + PERSONAL_TOKEN: ${{ secrets.GITHUB_TOKEN }} + PUBLISH_BRANCH: gh-pages + PUBLISH_DIR: allure-history + + - name: Check tests are passed + if: ${{ steps.functests.outcome != 'success' }} + run: | + echo Tests result: ${{ steps.functests.outcome }} + exit 1 From 695733d7637dd925d828eb79983e3c67ca66fca9 Mon Sep 17 00:00:00 2001 From: Aleksandr_Vorobev Date: Fri, 19 Jan 2024 00:06:44 +0300 Subject: [PATCH 25/28] add github actions update pom --- .github/workflows/build.yml | 37 +------------------------------- pom.xml | 4 ++++ src/test/java/test/BaseTest.java | 12 ++++++++--- 3 files changed, 14 insertions(+), 39 deletions(-) diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml index fc2d0ea..5bc1949 100644 --- a/.github/workflows/build.yml +++ b/.github/workflows/build.yml @@ -11,7 +11,7 @@ on: branches: - main release: - types: # This configuration does not affect the page_build event above + types: - created jobs: @@ -37,47 +37,12 @@ jobs: id: build run: mvn clean install -DskipTests -ntp - - name: Start Selenoid - uses: Xotabu4/selenoid-github-action@v2 - id: start-selenoid - - - name: Check Selenoid has been started - run: curl http://localhost:4444/status - - name: Tests id: functests timeout-minutes: 10 continue-on-error: true run: mvn test -ntp - - name: Get Allure history - uses: actions/checkout@v3 - id: allure-setup - continue-on-error: true - with: - ref: gh-pages - path: gh-pages - - - name: Generate Allure report - uses: simple-elf/allure-report-action@master - with: - allure_results: target/allure-results - allure_report: target/allure-report - allure_history: allure-history - - - name: Upload Allure report - uses: actions/upload-artifact@master - with: - name: Allure report - path: target/allure-report - - - name: Deploy Allure report to Github Pages - uses: peaceiris/actions-gh-pages@v2 - env: - PERSONAL_TOKEN: ${{ secrets.GITHUB_TOKEN }} - PUBLISH_BRANCH: gh-pages - PUBLISH_DIR: allure-history - - name: Check tests are passed if: ${{ steps.functests.outcome != 'success' }} run: | diff --git a/pom.xml b/pom.xml index 4655ce7..baadba3 100644 --- a/pom.xml +++ b/pom.xml @@ -19,6 +19,10 @@ 2.12.0 3.8.1 2.22.2 + + https://example.com + true + chrome diff --git a/src/test/java/test/BaseTest.java b/src/test/java/test/BaseTest.java index e177652..05edc88 100644 --- a/src/test/java/test/BaseTest.java +++ b/src/test/java/test/BaseTest.java @@ -9,17 +9,23 @@ import org.testng.annotations.Listeners; import static com.codeborne.selenide.FileDownloadMode.FOLDER; +import static java.lang.Boolean.parseBoolean; +import static java.lang.System.getProperty; @Listeners() public interface BaseTest { + String baseUrl = getProperty("base.url", "https://example.com"); + String browser = getProperty("browser", "chrome"); + boolean headless = parseBoolean(getProperty("headless", "true")); + @BeforeSuite public static void setUp() { SelenideLogger.addListener("AllureSelenide", new AllureSelenide().screenshots(true) .savePageSource(false)); - Configuration.baseUrl = "https://www.example.com"; - Configuration.browser = "chrome"; // You can also use "firefox", "edge", etc. + Configuration.baseUrl = baseUrl; + Configuration.browser = browser; // You can also use "firefox", "edge", etc. Configuration.pageLoadTimeout = 20000; - Configuration.headless = false; + Configuration.headless = headless; Configuration.browserSize = "1920x1200"; Configuration.screenshots = true; Configuration.fileDownload = FOLDER; From 30e6db987b8e3cd4b41dac5a0e5672c33b7eb0cd Mon Sep 17 00:00:00 2001 From: Aleksandr_Vorobev Date: Fri, 19 Jan 2024 00:10:09 +0300 Subject: [PATCH 26/28] add github actions update pom --- .github/workflows/build.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml index 5bc1949..72fbc0a 100644 --- a/.github/workflows/build.yml +++ b/.github/workflows/build.yml @@ -47,4 +47,4 @@ jobs: if: ${{ steps.functests.outcome != 'success' }} run: | echo Tests result: ${{ steps.functests.outcome }} - exit 1 + exit 1 \ No newline at end of file From 5a2bc31f7a99fabcd5c94fd9c38181ef8effe130 Mon Sep 17 00:00:00 2001 From: Aleksandr_Vorobev Date: Fri, 19 Jan 2024 00:13:40 +0300 Subject: [PATCH 27/28] upd pom --- pom.xml | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/pom.xml b/pom.xml index baadba3..47014fd 100644 --- a/pom.xml +++ b/pom.xml @@ -19,6 +19,8 @@ 2.12.0 3.8.1 2.22.2 + 11 + 11 https://example.com true @@ -99,8 +101,8 @@ maven-compiler-plugin ${maven.compiler.plugin.version} - 8 - 8 + ${maven.compiler.source} + ${maven.compiler.target} From 5e35adb28080c1afce2f57102f2876565bdcf29f Mon Sep 17 00:00:00 2001 From: Aleksandr_Vorobev Date: Tue, 23 Jan 2024 12:56:15 +0300 Subject: [PATCH 28/28] upd pom --- pom.xml | 12 ++---------- src/main/java/pages/BasePage.java | 2 +- src/test/java/test/BaseTest.java | 1 + 3 files changed, 4 insertions(+), 11 deletions(-) diff --git a/pom.xml b/pom.xml index 47014fd..16cc0c4 100644 --- a/pom.xml +++ b/pom.xml @@ -12,9 +12,8 @@ 7.8.0 2.7 2.22.0 - 5.25.1 + 6.19.1 1.18.22 - 7.0.4 2.13.6 2.12.0 3.8.1 @@ -45,7 +44,6 @@ com.codeborne selenide ${selenide.version} - compile @@ -61,18 +59,12 @@ ${lombok.version} test - - - com.codeborne - selenide-core - ${selenide.core.version} - + io.qameta.allure allure-testng ${allure.version} - io.qameta.allure allure-selenide diff --git a/src/main/java/pages/BasePage.java b/src/main/java/pages/BasePage.java index 252595c..33e120e 100644 --- a/src/main/java/pages/BasePage.java +++ b/src/main/java/pages/BasePage.java @@ -1,8 +1,8 @@ package pages; import com.codeborne.selenide.Selenide; -public abstract class BasePage { +public abstract class BasePage { protected String path; protected String title; diff --git a/src/test/java/test/BaseTest.java b/src/test/java/test/BaseTest.java index 05edc88..deacc13 100644 --- a/src/test/java/test/BaseTest.java +++ b/src/test/java/test/BaseTest.java @@ -32,6 +32,7 @@ public static void setUp() { } @AfterSuite + public static void tearDown() { SelenideLogger.removeListener("AllureSelenide"); Selenide.closeWebDriver();