5 / 3 / 0
Регистрация: 22.09.2019
Сообщений: 111
|
|
1
|
Элемент не успевает загрузиться на страницу
08.12.2021, 21:34. Показов 1003. Ответов 0
Я работаю с автотестами и веб-драйвером, и моя проблема в том, что элемент не успевает загружаться, хотя я добавил явное и неявное ожидание, мне действительно нужна ваша помощь, потому что я в ступоре.
Класс с тестами
Java | 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
80
81
82
83
84
85
86
87
88
89
90
91
92
| package test;
import org.junit.After;
import org.junit.Assert;
import org.junit.Before;
import org.junit.Test;
import org.openqa.selenium.*;
import org.openqa.selenium.chrome.ChromeDriver;
import org.openqa.selenium.chrome.ChromeOptions;
import org.openqa.selenium.support.ui.ExpectedConditions;
import org.openqa.selenium.support.ui.WebDriverWait;
import org.testng.annotations.*;
import pages.HomePage;
import pages.LoginPage;
import java.util.concurrent.TimeUnit;
public class HelloWebDriver {
private WebDriver driver;
private ChromeOptions options;
private LoginPage loginPageObj;
private HomePage homePage;
private WebDriverWait wait;
@Before
public void browserSetup() {
System.out.println("aaa");
options = new ChromeOptions();
options.setPageLoadStrategy(PageLoadStrategy.NONE);
options.addArguments("start-maximized");
options.addArguments("disable-infobars");
driver = new ChromeDriver(options);
driver.manage().timeouts().implicitlyWait(5000,
TimeUnit.MILLISECONDS);
driver.manage().timeouts().pageLoadTimeout(5000,
TimeUnit.MILLISECONDS);
driver.manage().timeouts().setScriptTimeout(5000,
TimeUnit.MILLISECONDS);
driver.manage().timeouts().implicitlyWait(50, TimeUnit.SECONDS);
System.setProperty("webdriver.chrome.driver", "chromedriver.exe");
driver.get("https://junior.webquik.ru/");
wait = new WebDriverWait(driver,10);
}
@org.junit.Test
public void signIntoSystem() throws InterruptedException {
wait.until(ExpectedConditions.presenceOfElementLocated
(By.id("textfield-1015-inputEl")));
wait.until(ExpectedConditions.presenceOfElementLocated
(By.id("textfield-1017-inputEl")));
wait.until(ExpectedConditions.presenceOfElementLocated
(By.id("button-1021-btnIconEl")));
loginPageObj = new LoginPage(driver);
loginPageObj.singIntoSystemAsUser("U0191767","06258");
Assert.assertEquals(driver.getTitle(),"webQUIK 7.6.2");
}
@org.junit.Test
public void createNewTicketWithLimits() throws InterruptedException {
wait.until(ExpectedConditions.presenceOfElementLocated
(By.xpath("//*[@id=\"textfield-1015-inputEl\"]")));
wait.until(ExpectedConditions.presenceOfElementLocated
(By.xpath("//*[@id=\"textfield-1017-inputEl\"]")));
wait.until(ExpectedConditions.presenceOfElementLocated
(By.xpath("//*[@id=\"button-1021-btnIconEl\"]")));
loginPageObj = new LoginPage(driver);
loginPageObj.singIntoSystemAsUser("U0191767","06258");
Thread.sleep(5000);
Assert.assertEquals(driver.getTitle(),"webQUIK 7.6.2");
homePage.createNewTicketWithlimits("CNYRUB_SPT","5","1");
}
@Test
public void createNewTicketWithMarketablePrice() throws InterruptedException {
Thread.sleep(5000);
loginPageObj.singIntoSystemAsUser("U0191767","06258");
Thread.sleep(5000);
Assert.assertEquals(driver.getTitle(),"webQUIK 7.6.2");
homePage.createNewTicketWithMarket("CHMF","5");
}
@After
public void closeBrowser() {
driver.quit();
driver = null;
}
} |
|
LoginPage
Java | 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
| public class LoginPage {
private WebDriver driver = new ChromeDriver();
private WebElement loginFiled = driver.findElement(By.id("textfield-1015-inputEl"));
private WebElement passwordField = driver.findElement(By.id("textfield-1017-inputEl"));
private WebElement signButton = driver.findElement(By.id("button-1021-btnIconEl"));
/*
@FindBy(xpath = "//*[@id=\"textfield-1015-inputEl\"]")
private WebElement loginFiled;
@FindBy(xpath = "//*[@id=\"textfield-1017-inputEl\"]")
private WebElement passwordField;
@FindBy(xpath = "//*[@id=\"button-1021-btnIconEl\"]")
private WebElement signButton;
*/
public LoginPage(WebDriver driver) {
this.driver=driver;
// PageFactory.initElements(driver, this);
}
public void singIntoSystemAsUser(String login,String password) {
loginFiled.sendKeys(login);
passwordField.sendKeys(password);
signButton.click();
}
} |
|
0
|