forms
This commit is contained in:
parent
233f276f6f
commit
295204768e
1598
selenide_series/build/reports/tests/1692196445243.0.html
Normal file
1598
selenide_series/build/reports/tests/1692196445243.0.html
Normal file
File diff suppressed because one or more lines are too long
BIN
selenide_series/build/reports/tests/1692196445243.0.png
Normal file
BIN
selenide_series/build/reports/tests/1692196445243.0.png
Normal file
Binary file not shown.
After Width: | Height: | Size: 191 KiB |
745
selenide_series/build/reports/tests/1692204561236.0.html
Normal file
745
selenide_series/build/reports/tests/1692204561236.0.html
Normal file
File diff suppressed because one or more lines are too long
BIN
selenide_series/build/reports/tests/1692204561236.0.png
Normal file
BIN
selenide_series/build/reports/tests/1692204561236.0.png
Normal file
Binary file not shown.
After Width: | Height: | Size: 86 KiB |
745
selenide_series/build/reports/tests/1692204629062.0.html
Normal file
745
selenide_series/build/reports/tests/1692204629062.0.html
Normal file
File diff suppressed because one or more lines are too long
BIN
selenide_series/build/reports/tests/1692204629062.0.png
Normal file
BIN
selenide_series/build/reports/tests/1692204629062.0.png
Normal file
Binary file not shown.
After Width: | Height: | Size: 86 KiB |
745
selenide_series/build/reports/tests/1692204662965.0.html
Normal file
745
selenide_series/build/reports/tests/1692204662965.0.html
Normal file
File diff suppressed because one or more lines are too long
BIN
selenide_series/build/reports/tests/1692204662965.0.png
Normal file
BIN
selenide_series/build/reports/tests/1692204662965.0.png
Normal file
Binary file not shown.
After Width: | Height: | Size: 59 KiB |
745
selenide_series/build/reports/tests/1692204712338.0.html
Normal file
745
selenide_series/build/reports/tests/1692204712338.0.html
Normal file
File diff suppressed because one or more lines are too long
BIN
selenide_series/build/reports/tests/1692204712338.0.png
Normal file
BIN
selenide_series/build/reports/tests/1692204712338.0.png
Normal file
Binary file not shown.
After Width: | Height: | Size: 59 KiB |
@ -5,8 +5,9 @@ TestNG ---> https://mvnrepository.com/artifact/org.testng/testng (pom.xml)
|
|||||||
|
|
||||||
Maven --->
|
Maven --->
|
||||||
|
|
||||||
|
''''
|
||||||
<properties>
|
<properties>
|
||||||
<maven.compiler.source>20</maven.compiler.source>
|
<maven.compiler.source>20</maven.compiler.source>
|
||||||
<maven.compiler.target>20</maven.compiler.target>
|
<maven.compiler.target>20</maven.compiler.target>
|
||||||
</properties>
|
</properties>
|
||||||
|
'''
|
||||||
|
31
selenide_series/src/test/java/specs/FormTest.java
Normal file
31
selenide_series/src/test/java/specs/FormTest.java
Normal file
@ -0,0 +1,31 @@
|
|||||||
|
package specs;
|
||||||
|
|
||||||
|
|
||||||
|
import com.codeborne.selenide.Condition;
|
||||||
|
import org.testng.annotations.Test;
|
||||||
|
|
||||||
|
import static com.codeborne.selenide.Selenide.$;
|
||||||
|
import static com.codeborne.selenide.Selenide.open;
|
||||||
|
|
||||||
|
// zde otestujeme dotazník pro zákazníka který vyplníme.
|
||||||
|
public class FormTest {
|
||||||
|
@Test
|
||||||
|
public void testFormFields() {
|
||||||
|
open("https://practice.sdetunicorns.com/support-form/");
|
||||||
|
|
||||||
|
// vyplň všechny pole
|
||||||
|
$(".support-name input").val("Fanda");
|
||||||
|
$(".support-email input").val("Fanda@vidle.com");
|
||||||
|
$(".support-subject input").val("Nechce to splachovat");
|
||||||
|
// dropdown a checkbox
|
||||||
|
$(".support-dropdown select").selectOption("Technical Team");
|
||||||
|
$(".support-checkboxes ul li:nth-child(2) input").click();
|
||||||
|
// vyber datum
|
||||||
|
$(".support-date input").click();
|
||||||
|
$(".flatpickr-day.nextMonthDay").click();
|
||||||
|
// klikni na Submit tlačítkko
|
||||||
|
$("button[type=submit]").click();
|
||||||
|
// ověř submit zprávu
|
||||||
|
$("div[role=alert]").shouldHave(Condition.text("Thanks for contacting us! We will be in touch with you shortly."));
|
||||||
|
}
|
||||||
|
}
|
@ -1,11 +1,17 @@
|
|||||||
package specs;
|
package specs;
|
||||||
|
|
||||||
|
import com.codeborne.selenide.CollectionCondition;
|
||||||
|
import com.codeborne.selenide.ElementsCollection;
|
||||||
import com.codeborne.selenide.WebDriverRunner;
|
import com.codeborne.selenide.WebDriverRunner;
|
||||||
|
import org.openqa.selenium.By;
|
||||||
import org.openqa.selenium.WebDriver;
|
import org.openqa.selenium.WebDriver;
|
||||||
import org.testng.annotations.Test;
|
import org.testng.annotations.Test;
|
||||||
|
// pro každou novou funkci pomocí AlT + Enter můžeme přidat hvězdičku a ušetříme řádky
|
||||||
|
import java.util.List;
|
||||||
|
|
||||||
import static com.codeborne.selenide.Selenide.open;
|
import static com.codeborne.selenide.Condition.*;
|
||||||
import static com.codeborne.selenide.Selenide.title;
|
import static com.codeborne.selenide.Selenide.*;
|
||||||
|
import static org.testng.Assert.assertTrue;
|
||||||
import static org.testng.AssertJUnit.assertEquals;
|
import static org.testng.AssertJUnit.assertEquals;
|
||||||
|
|
||||||
public class HomeTest {
|
public class HomeTest {
|
||||||
@ -24,6 +30,46 @@ public class HomeTest {
|
|||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void testInteractingWithElements() {
|
public void testInteractingWithElements() {
|
||||||
|
open("https://practice.sdetunicorns.com/");
|
||||||
|
|
||||||
|
// klikneme na tlačítko podle id
|
||||||
|
$(By.id("get-started")).click();
|
||||||
|
|
||||||
|
// zkontrolujeme očekávanou URL máme dva způsoby
|
||||||
|
String url = WebDriverRunner.url();
|
||||||
|
//assertEquals(url, "https://practice.sdetunicorns.com/#get-started");
|
||||||
|
assertTrue(url.contains("get-started"));
|
||||||
|
|
||||||
|
// najdeme objeckt podle cssSelector a zkontrolujeme jeho text ( zde je to třída h1 class )
|
||||||
|
$("h1")
|
||||||
|
.should(text("Think different. Make different."));
|
||||||
|
|
||||||
|
// Ověříme logo pomocí xpath
|
||||||
|
$(By.xpath("//*[@id=\"zak-masthead\"]/div/div/div/div[1]/div/a/img"))
|
||||||
|
.should(be(visible));
|
||||||
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
|
public void testMultipleElements() {
|
||||||
|
open("https://practice.sdetunicorns.com/");
|
||||||
|
|
||||||
|
// zkontrolujeme názvy v menu (horní lišta)
|
||||||
|
// $$ znamená že pracujeme s více elementy
|
||||||
|
// vytvoříme si pak proměnou linklists
|
||||||
|
//za li[id. . .] už je id na položky v menu
|
||||||
|
List<String> expectedLinks = List.of("Home", "About", "Shop", "Blog", "Contact", "My account");
|
||||||
|
ElementsCollection linkLists = $$("#zak-primary-menu li[id*=menu-item]");
|
||||||
|
|
||||||
|
// vypíšeme do console položky menu
|
||||||
|
System.out.println(linkLists.texts());
|
||||||
|
|
||||||
|
//porovnáme výsledek z našimy zadanými hodnoty na začátku testu
|
||||||
|
List<String> linkListsText = linkLists.texts();
|
||||||
|
assertEquals(linkListsText, expectedLinks);
|
||||||
|
// a kratší způsob zápisu
|
||||||
|
linkLists.shouldHave(CollectionCondition.texts(expectedLinks));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
BIN
selenide_series/target/test-classes/specs/FormTest.class
Normal file
BIN
selenide_series/target/test-classes/specs/FormTest.class
Normal file
Binary file not shown.
Binary file not shown.
Loading…
Reference in New Issue
Block a user