From db16b2c388bde6eec7db59e18cf9c8972be75ec6 Mon Sep 17 00:00:00 2001 From: dezonnov1 Date: Thu, 12 Dec 2024 21:51:15 +0400 Subject: [PATCH] =?UTF-8?q?=D1=81=D0=BE=D0=B7=D0=B4=D0=B0=D0=BD=D1=8B=20?= =?UTF-8?q?=D1=82=D0=B5=D1=81=D1=82=D1=8B=20=D0=B7=D0=B0=D0=B4=D0=B0=D0=BD?= =?UTF-8?q?=D0=B8=D0=B5=205?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .idea/encodings.xml | 7 +++ pom.xml | 35 ++++++++++++++- src/main/java/org/example/Main.java | 8 ---- src/main/resources/testng.xml | 38 ++++++++++++++++ src/test/java/ExampleSLF4J.java | 28 ++++++++++++ src/test/java/ExampleSelenide.java | 34 +++++++++++++++ src/test/java/ExampleTestNG.java | 68 +++++++++++++++++++++++++++++ 7 files changed, 209 insertions(+), 9 deletions(-) create mode 100644 .idea/encodings.xml create mode 100644 src/main/resources/testng.xml create mode 100644 src/test/java/ExampleSLF4J.java create mode 100644 src/test/java/ExampleSelenide.java create mode 100644 src/test/java/ExampleTestNG.java diff --git a/.idea/encodings.xml b/.idea/encodings.xml new file mode 100644 index 0000000..aa00ffa --- /dev/null +++ b/.idea/encodings.xml @@ -0,0 +1,7 @@ + + + + + + + \ No newline at end of file diff --git a/pom.xml b/pom.xml index 0037d81..cf721e6 100644 --- a/pom.xml +++ b/pom.xml @@ -13,5 +13,38 @@ 17 UTF-8 - + + + + org.testng + testng + 7.10.2 + test + + + + com.codeborne + selenide + 7.5.1 + + + + io.qameta.allure + allure-testng + 2.29.0 + + + + org.slf4j + slf4j-simple + 2.0.16 + test + + + + org.slf4j + slf4j-api + 2.0.16 + + \ No newline at end of file diff --git a/src/main/java/org/example/Main.java b/src/main/java/org/example/Main.java index a02700f..ecfd5a9 100644 --- a/src/main/java/org/example/Main.java +++ b/src/main/java/org/example/Main.java @@ -4,14 +4,6 @@ // click the icon in the gutter. public class Main { public static void main(String[] args) { - //TIP Press with your caret at the highlighted text - // to see how IntelliJ IDEA suggests fixing it. - System.out.printf("Hello and welcome!"); - for (int i = 1; i <= 5; i++) { - //TIP Press to start debugging your code. We have set one breakpoint - // for you, but you can always add more by pressing . - System.out.println("i = " + i); - } } } \ No newline at end of file diff --git a/src/main/resources/testng.xml b/src/main/resources/testng.xml new file mode 100644 index 0000000..f7025eb --- /dev/null +++ b/src/main/resources/testng.xml @@ -0,0 +1,38 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/src/test/java/ExampleSLF4J.java b/src/test/java/ExampleSLF4J.java new file mode 100644 index 0000000..3dc7178 --- /dev/null +++ b/src/test/java/ExampleSLF4J.java @@ -0,0 +1,28 @@ +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; +import org.testng.annotations.Test; + +public class ExampleSLF4J { + private static Logger logger = LoggerFactory.getLogger(ExampleSLF4J.class); + + @Test + public void sendTrace() { + logger.trace("Пробрасываем тросы для мостов"); + } + @Test + public void sendInfo() { + logger.info("Тросы проброшены"); + } + @Test + public void sendDebug() { + logger.debug("Пробросили тросы в с помощью каната)"); + } + @Test + public void sendWarning() { + logger.warn("Тросы могут упасть"); + } + @Test + public void sendError(){ + logger.error("Тросы падают вверх!!!"); + } +} diff --git a/src/test/java/ExampleSelenide.java b/src/test/java/ExampleSelenide.java new file mode 100644 index 0000000..1adc021 --- /dev/null +++ b/src/test/java/ExampleSelenide.java @@ -0,0 +1,34 @@ +import com.codeborne.selenide.Selenide; +import org.slf4j.helpers.Slf4jEnvUtil; +import org.testng.Assert; +import com.codeborne.selenide.Condition; +import org.openqa.selenium.By; +import org.testng.annotations.Test; + +public class ExampleSelenide { + @Test + public void simbirsoftFeedBack(){ + Selenide.open("https://www.simbirsoft.com/"); + Selenide.$(By.cssSelector("a[class=\"gh-tools-feedback write-to-us\"]")) + .shouldBe(Condition.visible) + .click(); + } + + /** + * Заходим на сайт https://www.planetminecraft.com + * наводимся на выпадающее меню Minecraft + * нажимаем на кнопку Servers, которая добавляет к текущей ссылке /servers/ + * проверяем соответствие ссылки с https://www.planetminecraft.com/servers/ + */ + @Test + public void planetMCMenu(){ + Selenide.open("https://www.planetminecraft.com"); + Selenide.$(By.xpath("//a [@class='nav_dropdown' and @id='menu_resources']")) + .hover(); + Selenide.$(By.xpath("//a[@data-id = 'servers/' and @title='Minecraft Servers']")) + .shouldBe(Condition.visible) + .click(); + Assert.assertEquals(Selenide.webdriver().driver().url(),"https://www.planetminecraft.com/servers/" + ,"открылся не https://www.planetminecraft.com/servers/"); + } +} diff --git a/src/test/java/ExampleTestNG.java b/src/test/java/ExampleTestNG.java new file mode 100644 index 0000000..75762d5 --- /dev/null +++ b/src/test/java/ExampleTestNG.java @@ -0,0 +1,68 @@ +import org.testng.Assert; +import org.testng.annotations.DataProvider; +import org.testng.annotations.Parameters; +import org.testng.annotations.Test; +import org.testng.asserts.SoftAssert; + + +public class ExampleTestNG { +//suite +// group +// test +// class +// method + + /** + * Простейший пример + */ + @Test + public void testCalc(){ + Assert.assertEquals(2+2,4,"Two plus two is FOUR!"); + } + + /** + * Проверка функции Math.pow() + * @param base число, которое возводится в степень + */ + @Test + @Parameters({"num"}) + public void testMathPow2(double base){ + Assert.assertEquals(Math.pow(base,2),base*base); + } + + /** + * Проверка имени и пароля + * @param name имя + * @param pas пароль + */ + @Test(description = "Check name and password") + @Parameters({"name","pas"}) + public void testLogin(String name, String pas){ + SoftAssert softAssert = new SoftAssert(); + softAssert.assertEquals(name, "VOVCHIK2005", "Login name incorrect"); + softAssert.assertEquals(pas, "CoolPass", "Login pas incorrect"); + softAssert.assertAll(); + } + + /** + * Проверка персон по их имени и фамилии + * @param personName имя персоны + * @param personLastName фамилия персоны + */ + @Test(dataProvider="persons") + public void personsCheckFromDataProvider(String personName, String personLastName){ + SoftAssert softAssert = new SoftAssert(); + softAssert.assertEquals(personName.matches("[PVS].+[a-z[A-Z]]"), true); + softAssert.assertEquals(personLastName.matches("[PBK].+in"), true); + softAssert.assertAll(); + } + @DataProvider(name = "persons") + public static Object[][] allPersons(){ + return new Object[][]{ + {"Petya","Pushin"}, + {"Vanya","Bashin"}, + {"Olga","Balka"}, + {"Semen","Kavkin"} + }; + } +}