/
SetBrowserVersion.java
45 lines (37 loc) · 1.54 KB
/
SetBrowserVersion.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
package com.anhtester;
import com.anhtester.keywords.WebUI;
import org.openqa.selenium.By;
import org.openqa.selenium.WebDriver;
import org.openqa.selenium.chrome.ChromeDriver;
import org.openqa.selenium.chrome.ChromeOptions;
import org.testng.annotations.AfterMethod;
import org.testng.annotations.BeforeMethod;
import org.testng.annotations.Test;
import java.time.Duration;
public class SetBrowserVersion {
private WebDriver driver;
@BeforeMethod
public void createDriver() {
//Đang dùng Selenium 4.11.0 (chỉ support đến CDP 115)
System.setProperty("webdriver.http.factory", "jdk-http-client");
ChromeOptions options = new ChromeOptions();
options.setBrowserVersion("115");
driver = new ChromeDriver(options);
driver.manage().window().maximize();
driver.manage().timeouts().pageLoadTimeout(Duration.ofSeconds(30));
driver.manage().timeouts().implicitlyWait(Duration.ofSeconds(10));
new WebUI(driver);
}
@Test(priority = 1)
public void testSetBrowserVersion() {
driver.get("https://crm.anhtester.com/admin/authentication");
driver.findElement(By.xpath("//input[@id='email']")).sendKeys("admin@example.com");
driver.findElement(By.xpath("//input[@id='password']")).sendKeys("123456");
driver.findElement(By.xpath("//button[normalize-space()='Login']")).click();
driver.findElement(By.xpath("//span[normalize-space()='Projects']")).click();
}
@AfterMethod
public void closeDriver() {
driver.quit();
}
}