Skip to content

Commit 2ad5094

Browse files
committed
com14
1 parent 28c0095 commit 2ad5094

1 file changed

Lines changed: 22 additions & 19 deletions

File tree

Lesson14/src/test/java/TestClass.java

Lines changed: 22 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,8 @@
88
import org.openqa.selenium.support.ui.WebDriverWait;
99

1010
import java.time.Duration;
11+
import java.util.ArrayList;
12+
import java.util.Arrays;
1113
import java.util.List;
1214
import java.util.concurrent.TimeUnit;
1315

@@ -31,19 +33,16 @@ void start() {
3133
void checkLabels() {
3234
WebElement btn = driver.findElement(By.xpath("//div[@class='pay__form']//button[@class='select__header']"));
3335
List<WebElement> list = driver.findElements(By.xpath("//div[@class='pay__form']//p[@class='select__option']"));
36+
List<String> titles = new ArrayList<>(Arrays.asList("Номер телефона", "Номер абонента", "Номер счета на 44", "Номер счета на 2073"));
3437
Actions builder = new Actions(driver);
35-
for (WebElement elem : list) {
38+
for (int i = 0; i < list.size(); ++i) {
3639
builder.click(btn).build().perform();
37-
WebDriverWait wait = new WebDriverWait(driver, Duration.ofSeconds(10));
38-
wait.until(ExpectedConditions.visibilityOfElementLocated(
39-
By.xpath("//div[@class='pay__form']//ul[@class='select__list']")));
40-
builder.pause(2000);
41-
builder.click(elem).build().perform();
42-
System.out.println(elem.getText() + ":");
43-
for (WebElement input : driver.findElements(By.xpath("//form[@class='pay-form opened']//input"))) {
44-
System.out.println(input.getAttribute("placeholder"));
45-
}
46-
System.out.println();
40+
builder.pause(1000);
41+
builder.click(list.get(i)).build().perform();
42+
List<WebElement> input = driver.findElements(By.xpath("//form[@class='pay-form opened']//input"));
43+
Assertions.assertEquals(titles.get(i), input.get(0).getAttribute("placeholder"));
44+
Assertions.assertEquals("Сумма", input.get(1).getAttribute("placeholder"));
45+
Assertions.assertEquals("E-mail для отправки чека", input.get(2).getAttribute("placeholder"));
4746
}
4847
}
4948

@@ -53,6 +52,7 @@ void checkFrame() {
5352
WebElement btn = driver.findElement(By.xpath("//div[@class='pay__wrapper']//button[text()='Продолжить']"));
5453
WebElement phoneField = driver.findElement(By.xpath("//div[@class='pay__wrapper']//input[@class='phone']"));
5554
WebElement moneyField = driver.findElement(By.xpath("//div[@class='pay__wrapper']//input[@class='total_rub']"));
55+
List<String> titles = new ArrayList<>(Arrays.asList("Номер карты", "Срок действия", "CVC", "Имя держателя (как на карте)"));
5656
Actions builder = new Actions(driver);
5757
builder.sendKeys(phoneField, "297777777").build().perform();
5858
builder.sendKeys(moneyField, "100").build().perform();
@@ -66,19 +66,22 @@ void checkFrame() {
6666
WebElement btnLb = driver.findElement(By.xpath("//button[contains(@class,'colored disabled')]"));
6767
List<WebElement> labels = driver.findElements(By.xpath(
6868
"//div[@class='app-wrapper__content']//div[contains(@class, 'card ng-tns')]//label"));
69-
System.out.println(sum.getText());
70-
System.out.println(hd.getText());
71-
System.out.println(btnLb.getText());
72-
System.out.println();
73-
for (WebElement label : labels) {
74-
System.out.println(label.getText());
69+
Assertions.assertTrue(sum.getText().contains("100"));
70+
Assertions.assertTrue(btnLb.getText().contains("100"));
71+
Assertions.assertTrue(hd.getText().contains("297777777"));
72+
for (int i = 0; i < 4; ++i) {
73+
Assertions.assertEquals(titles.get(i), labels.get(i).getText());
74+
}
75+
List<WebElement> card_brands = driver.findElements(By.xpath("//div[@class='app-wrapper__content']//" +
76+
"div[contains(@class, 'cards-brands')]//img"));
77+
for (WebElement elem : card_brands) {
78+
Assertions.assertTrue(elem.isDisplayed());
7579
}
76-
Assertions.assertTrue(driver.findElement(
77-
By.xpath("//div[@class='app-wrapper__content']//div[contains(@class, 'cards-brands')]")).isDisplayed());
7880
}
7981

8082
@AfterEach
8183
void finish() {
84+
driver.close();
8285
driver.quit();
8386
}
8487
}

0 commit comments

Comments
 (0)