-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathTextBoxTests.java
More file actions
75 lines (57 loc) · 2.22 KB
/
TextBoxTests.java
File metadata and controls
75 lines (57 loc) · 2.22 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
package tests;
import org.junit.jupiter.api.Test;
import static com.codeborne.selenide.Condition.cssClass;
import static com.codeborne.selenide.Condition.text;
import static com.codeborne.selenide.Selenide.$;
import static com.codeborne.selenide.Selenide.open;
public class TextBoxTests {
@Test
void fillFormTest() {
open("https://demoqa.com/text-box");
$("#userName").val("Alex");
$("#userEmail").val("Egorov@alex.com");
$("#currentAddress").val("Montenegro");
$("#permanentAddress").val("Street 1");
$("#submit").click();
$("#output").shouldHave(text("Name:Alex\n" +
"Email:Egorov@alex.com\n" +
"Current Address :Montenegro\n" +
"Permananet Address :Street 1"));
System.out.printf("");
}
@Test
void fillFormWithVariablesTest() {
String userName = "Alex",
email = "Egorov@alex.com",
currentAddress = "Montenegro",
permanentAddress = "Street 1";
open("https://demoqa.com/text-box");
$("#userName").val(userName);
$("#userEmail").val(email);
$("#currentAddress").val(currentAddress);
$("#permanentAddress").val(permanentAddress);
$("#submit").click();
$("#output").shouldHave(text(
"Name:" + userName + "\n" +
"Email:Egorov@alex.com\n" +
"Current Address :Montenegro\n" +
"Permananet Address :Street 1"));
$("#output").shouldHave(text(String.format(
"Name:%s\n" +
"Email:%s\n" +
"Current Address :Montenegro\n" +
"Permananet Address :Street 1", userName, email)));
$("#name").shouldHave(text(userName));
}
@Test
void wrongEmailTest() {
open("https://demoqa.com/text-box");
$("#userName").val("Alex");
$("#userEmail").val("Egorov");
$("#currentAddress").val("Montenegro");
$("#permanentAddress").val("Street 1");
$("#submit").click();
$("#userEmail").shouldHave(cssClass("field-error"));
System.out.printf("");
}
}