From b28ba2061017c43e13e79b2cde70f6d105821aec Mon Sep 17 00:00:00 2001 From: Ihar_Lipko Date: Mon, 27 Mar 2023 16:52:54 +0200 Subject: [PATCH 1/2] material-ui: Test material-ui elements. --- pom.xml | 4 +- .../example/baeldung/pages/ContactPage.java | 9 +- .../example/site/pages/ContactPage.java | 6 +- src/test/java/fewpageobjects/TestsInit.java | 8 +- .../fewpageobjects/tests/ContactsExample.java | 242 +++++++++++++++++- .../pageobject/tests/PageObjectExample.java | 2 + src/test/resources/general.xml | 2 +- 7 files changed, 260 insertions(+), 13 deletions(-) diff --git a/pom.xml b/pom.xml index 4edabf8..b67ef2c 100644 --- a/pom.xml +++ b/pom.xml @@ -12,7 +12,7 @@ UTF-8 1.9.6 - chrome + edge https://epam.github.io/JDI/ 2.13.8 2.10.0 @@ -25,7 +25,7 @@ com.epam.jdi - jdi-light-html + jdi-light-material-ui RELEASE diff --git a/src/main/java/pageobject/uiobjects/example/baeldung/pages/ContactPage.java b/src/main/java/pageobject/uiobjects/example/baeldung/pages/ContactPage.java index d5d6eb4..b676caf 100644 --- a/src/main/java/pageobject/uiobjects/example/baeldung/pages/ContactPage.java +++ b/src/main/java/pageobject/uiobjects/example/baeldung/pages/ContactPage.java @@ -11,8 +11,9 @@ @Url("/contact") @Title("Contact Us | Baeldung") public class ContactPage extends WebPage { - @UI("[name=your-name]") TextField firstName; - @UI("[name=your-email]") TextField email; - @UI("[name=your-message]") TextArea message; - @UI("//*[@value='Send your message']") Button send; + @UI("[name=your-name]") public TextField firstName; + @UI("[name=your-email]") public TextField email; + @UI("[name=your-message]") public TextArea message; + @UI("//*[@value='Send your message']") public Button send; + @UI("button.css-47sehv") public Button applyCookies; } diff --git a/src/main/java/pageobject/uiobjects/example/site/pages/ContactPage.java b/src/main/java/pageobject/uiobjects/example/site/pages/ContactPage.java index ffa93ab..6c3c000 100644 --- a/src/main/java/pageobject/uiobjects/example/site/pages/ContactPage.java +++ b/src/main/java/pageobject/uiobjects/example/site/pages/ContactPage.java @@ -1,7 +1,9 @@ package pageobject.uiobjects.example.site.pages; import com.epam.jdi.light.elements.composite.WebPage; - +import com.epam.jdi.light.elements.pageobjects.annotations.locators.JDropdown; +import com.epam.jdi.light.material.elements.inputs.Select; +//Add any element from material-ui package public class ContactPage extends WebPage { - +@JDropdown(root = "#select") public Select select; } diff --git a/src/test/java/fewpageobjects/TestsInit.java b/src/test/java/fewpageobjects/TestsInit.java index 358d6c2..fbb6778 100644 --- a/src/test/java/fewpageobjects/TestsInit.java +++ b/src/test/java/fewpageobjects/TestsInit.java @@ -1,6 +1,8 @@ package fewpageobjects; +import org.testng.annotations.AfterMethod; import org.testng.annotations.AfterSuite; +import org.testng.annotations.BeforeMethod; import org.testng.annotations.BeforeSuite; import pageobject.uiobjects.example.baeldung.BaeldungSite; @@ -11,14 +13,14 @@ import static pageobject.uiobjects.example.baeldung.BaeldungSite.homePage; public interface TestsInit { - @BeforeSuite(alwaysRun = true) + @BeforeMethod(alwaysRun = true) static void setUp() { - logger.setLogLevel(STEP); +// logger.setLogLevel(STEP); initElements(BaeldungSite.class); homePage.open(); } - @AfterSuite(alwaysRun = true) + @AfterMethod(alwaysRun = true) static void teardown() { close(); } diff --git a/src/test/java/fewpageobjects/tests/ContactsExample.java b/src/test/java/fewpageobjects/tests/ContactsExample.java index 497466d..2dadd39 100644 --- a/src/test/java/fewpageobjects/tests/ContactsExample.java +++ b/src/test/java/fewpageobjects/tests/ContactsExample.java @@ -1,6 +1,7 @@ package fewpageobjects.tests; import fewpageobjects.TestsInit; +import org.testng.annotations.BeforeMethod; import org.testng.annotations.Test; import pageobject.uiobjects.example.baeldung.entities.ContactInfo; @@ -12,10 +13,249 @@ public class ContactsExample implements TestsInit { c.email = "roman.iovlev.jdi@gmail.com"; c.message = "Hi Baeldung!";} ); + @BeforeMethod(alwaysRun = true) + public void applyCookies() { + if (contactPage.applyCookies.isDisplayed()) contactPage.applyCookies.click(); + } + @Test + public void fillContactTest1() throws InterruptedException { + contactPage.open(); + contactPage.asForm().send(MY_CONTACT); + contactPage.asForm().check(MY_CONTACT); + Thread.sleep(2000); + } + + @Test + public void fillContactTest2() throws InterruptedException { + contactPage.open(); + contactPage.asForm().send(MY_CONTACT); + contactPage.asForm().check(MY_CONTACT); + Thread.sleep(2000); + } + + @Test + public void fillContactTest3() throws InterruptedException { + contactPage.open(); + contactPage.asForm().send(MY_CONTACT); + contactPage.asForm().check(MY_CONTACT); + Thread.sleep(2000); + } + + @Test + public void fillContactTest4() throws InterruptedException { + contactPage.open(); + contactPage.asForm().send(MY_CONTACT); + contactPage.asForm().check(MY_CONTACT); + Thread.sleep(2000); + } + + @Test + public void fillContactTest5() throws InterruptedException { + contactPage.open(); + contactPage.asForm().send(MY_CONTACT); + contactPage.asForm().check(MY_CONTACT); + Thread.sleep(2000); + } + + @Test + public void fillContactTest6() throws InterruptedException { + contactPage.open(); + contactPage.asForm().send(MY_CONTACT); + contactPage.asForm().check(MY_CONTACT); + Thread.sleep(2000); + } + + @Test + public void fillContactTest7() throws InterruptedException { + contactPage.open(); + contactPage.asForm().send(MY_CONTACT); + contactPage.asForm().check(MY_CONTACT); + Thread.sleep(2000); + } + + @Test + public void fillContactTest8() throws InterruptedException { + contactPage.open(); + contactPage.asForm().send(MY_CONTACT); + contactPage.asForm().check(MY_CONTACT); + Thread.sleep(2000); + } + + @Test + public void fillContactTest9() throws InterruptedException { + contactPage.open(); + contactPage.asForm().send(MY_CONTACT); + contactPage.asForm().check(MY_CONTACT); + Thread.sleep(2000); + } + + @Test + public void fillContactTest10() throws InterruptedException { + contactPage.open(); + contactPage.asForm().send(MY_CONTACT); + contactPage.asForm().check(MY_CONTACT); + Thread.sleep(2000); + } + + @Test + public void fillContactTest11() throws InterruptedException { + contactPage.open(); + contactPage.asForm().send(MY_CONTACT); + contactPage.asForm().check(MY_CONTACT); + Thread.sleep(2000); + } + + @Test + public void fillContactTest12() throws InterruptedException { + contactPage.open(); + contactPage.asForm().send(MY_CONTACT); + contactPage.asForm().check(MY_CONTACT); + Thread.sleep(2000); + } + + @Test + public void fillContactTest13() throws InterruptedException { + contactPage.open(); + contactPage.asForm().send(MY_CONTACT); + contactPage.asForm().check(MY_CONTACT); + Thread.sleep(2000); + } + + @Test + public void fillContactTest14() throws InterruptedException { + contactPage.open(); + contactPage.asForm().send(MY_CONTACT); + contactPage.asForm().check(MY_CONTACT); + Thread.sleep(2000); + } + + @Test + public void fillContactTest15() throws InterruptedException { + contactPage.open(); + contactPage.asForm().send(MY_CONTACT); + contactPage.asForm().check(MY_CONTACT); + Thread.sleep(2000); + } + + @Test + public void fillContactTest16() throws InterruptedException { + contactPage.open(); + contactPage.asForm().send(MY_CONTACT); + contactPage.asForm().check(MY_CONTACT); + Thread.sleep(2000); + } + + @Test + public void fillContactTest17() throws InterruptedException { + contactPage.open(); + contactPage.asForm().send(MY_CONTACT); + contactPage.asForm().check(MY_CONTACT); + Thread.sleep(2000); + } + + @Test + public void fillContactTest18() throws InterruptedException { + contactPage.open(); + contactPage.asForm().send(MY_CONTACT); + contactPage.asForm().check(MY_CONTACT); + Thread.sleep(2000); + } + + @Test + public void fillContactTest19() throws InterruptedException { + contactPage.open(); + contactPage.asForm().send(MY_CONTACT); + contactPage.asForm().check(MY_CONTACT); + Thread.sleep(2000); + } +/* + + @Test + public void fillContactTest20() throws InterruptedException { + contactPage.open(); + contactPage.asForm().send(MY_CONTACT); + contactPage.asForm().check(MY_CONTACT); + Thread.sleep(2000); + } + + @Test + public void fillContactTest21() throws InterruptedException { + contactPage.open(); + contactPage.asForm().send(MY_CONTACT); + contactPage.asForm().check(MY_CONTACT); + Thread.sleep(2000); + } + + @Test + public void fillContactTest22() throws InterruptedException { + contactPage.open(); + contactPage.asForm().send(MY_CONTACT); + contactPage.asForm().check(MY_CONTACT); + Thread.sleep(2000); + } + + @Test + public void fillContactTest23() throws InterruptedException { + contactPage.open(); + contactPage.asForm().send(MY_CONTACT); + contactPage.asForm().check(MY_CONTACT); + Thread.sleep(2000); + } + + @Test + public void fillContactTest24() throws InterruptedException { + contactPage.open(); + contactPage.asForm().send(MY_CONTACT); + contactPage.asForm().check(MY_CONTACT); + Thread.sleep(2000); + } + + @Test + public void fillContactTest25() throws InterruptedException { + contactPage.open(); + contactPage.asForm().send(MY_CONTACT); + contactPage.asForm().check(MY_CONTACT); + Thread.sleep(2000); + } + + @Test + public void fillContactTest26() throws InterruptedException { + contactPage.open(); + contactPage.asForm().send(MY_CONTACT); + contactPage.asForm().check(MY_CONTACT); + Thread.sleep(2000); + } + + @Test + public void fillContactTest27() throws InterruptedException { + contactPage.open(); + contactPage.asForm().send(MY_CONTACT); + contactPage.asForm().check(MY_CONTACT); + Thread.sleep(2000); + } + + @Test + public void fillContactTest28() throws InterruptedException { + contactPage.open(); + contactPage.asForm().send(MY_CONTACT); + contactPage.asForm().check(MY_CONTACT); + Thread.sleep(2000); + } + + @Test + public void fillContactTest29() throws InterruptedException { + contactPage.open(); + contactPage.asForm().send(MY_CONTACT); + contactPage.asForm().check(MY_CONTACT); + Thread.sleep(2000); + } + @Test - public void fillContactTest() { + public void fillContactTest30() throws InterruptedException { contactPage.open(); contactPage.asForm().send(MY_CONTACT); contactPage.asForm().check(MY_CONTACT); + Thread.sleep(2000); } +*/ } diff --git a/src/test/java/pageobject/tests/PageObjectExample.java b/src/test/java/pageobject/tests/PageObjectExample.java index 0aba280..3b74407 100644 --- a/src/test/java/pageobject/tests/PageObjectExample.java +++ b/src/test/java/pageobject/tests/PageObjectExample.java @@ -16,5 +16,7 @@ public void openPage() { loginButton.click(); menuContactForm.click(); contactPage.checkOpened(); + //fake call. We do not run this test. + contactPage.select.list(); } } diff --git a/src/test/resources/general.xml b/src/test/resources/general.xml index d40c15c..6a219d1 100644 --- a/src/test/resources/general.xml +++ b/src/test/resources/general.xml @@ -1,6 +1,6 @@ - + From f4fe00bfcfe214fb4ac4eda7c7ec18ce35b0bd65 Mon Sep 17 00:00:00 2001 From: Ihar_Lipko Date: Mon, 27 Mar 2023 19:54:42 +0200 Subject: [PATCH 2/2] material-test: Uncomment additional test cases. --- src/test/java/fewpageobjects/tests/ContactsExample.java | 2 -- src/test/resources/general.xml | 6 +++--- 2 files changed, 3 insertions(+), 5 deletions(-) diff --git a/src/test/java/fewpageobjects/tests/ContactsExample.java b/src/test/java/fewpageobjects/tests/ContactsExample.java index 2dadd39..8e874cd 100644 --- a/src/test/java/fewpageobjects/tests/ContactsExample.java +++ b/src/test/java/fewpageobjects/tests/ContactsExample.java @@ -168,7 +168,6 @@ public void fillContactTest19() throws InterruptedException { contactPage.asForm().check(MY_CONTACT); Thread.sleep(2000); } -/* @Test public void fillContactTest20() throws InterruptedException { @@ -257,5 +256,4 @@ public void fillContactTest30() throws InterruptedException { contactPage.asForm().check(MY_CONTACT); Thread.sleep(2000); } -*/ } diff --git a/src/test/resources/general.xml b/src/test/resources/general.xml index 6a219d1..b00a62f 100644 --- a/src/test/resources/general.xml +++ b/src/test/resources/general.xml @@ -1,11 +1,11 @@ - + - - + \ No newline at end of file