-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathRegisterCompanyTest.java
More file actions
79 lines (68 loc) · 2.33 KB
/
RegisterCompanyTest.java
File metadata and controls
79 lines (68 loc) · 2.33 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
76
77
78
79
import org.junit.jupiter.api.*;
import org.openqa.selenium.By;
import org.openqa.selenium.JavascriptExecutor;
import org.openqa.selenium.WebDriver;
import org.openqa.selenium.WebElement;
import org.openqa.selenium.support.ui.ExpectedConditions;
import org.openqa.selenium.support.ui.WebDriverWait;
import pages.BusinessPage;
import pages.HomePage;
import java.util.List;
import java.util.NoSuchElementException;
@TestMethodOrder(MethodOrderer.OrderAnnotation.class)
public class RegisterCompanyTest {
private static Utils utils;
private static WebDriver driver;
private static WebDriverWait wait;
private static JavascriptExecutor js;
private static HomePage homePage;
private static BusinessPage businessPage;
@BeforeAll
public static void setUp() {
utils = new Utils();
utils.setupDriver();
driver = utils.getDriver();
wait = utils.getWaitTime();
js = utils.getJsExecutor();
homePage = new HomePage(driver);
businessPage = new BusinessPage(driver);
}
@AfterAll
public static void tearDown() {
if(utils != null){
utils.quitDriver();
}
}
public void switchToFrameWithLocator(By element) {
List<WebElement> frames = driver.findElements(By.tagName("iframe"));
for (WebElement frame : frames) {
driver.switchTo().frame(frame);
List<WebElement> elements = driver.findElements(element);
if (!elements.isEmpty()) {
System.out.println("Нужный frame найден!");
return;
}
driver.switchTo().defaultContent();
}
throw new NoSuchElementException("Frame с элементом не найден!");
}
@Test
@Order(1)
public void auth() {
homePage.clickEnterButton();
By username = By.xpath("//input[@placeholder='Имя аккаунта']");
switchToFrameWithLocator(username);
homePage.enterLoginAndChooseMailType("test_qa_lab3");
homePage.enterNumbersAndCode("9", "5");
WebElement codeField = wait.until(ExpectedConditions.visibilityOfElementLocated(By.xpath("//input[@name='Code']")));
wait.until(driver -> codeField.getAttribute("value").length() == 8);
System.out.println("Код введен: " + codeField.getAttribute("value"));
homePage.submitLogin();
}
@Test
@Order(2)
public void registerCompanyTest() {
homePage.clickBusinessButton();
businessPage.registerCompany();
}
}