1729217903264_12306题目.zip
立即下载
资源介绍:
1729217903264_12306题目.zip
import org.apache.commons.io.FileUtils;
import org.junit.jupiter.api.AfterEach;
import org.junit.jupiter.api.BeforeEach;
import org.junit.jupiter.api.Test;
import org.junit.jupiter.params.ParameterizedTest;
import org.junit.jupiter.params.provider.CsvSource;
import org.openqa.selenium.*;
import org.openqa.selenium.chrome.ChromeDriver;
import java.io.File;
import java.util.concurrent.TimeUnit;
public class TestTemplate {
private WebDriver driver;
@BeforeEach
public void setup() {
System.setProperty("webdriver.chrome.driver", "C:\\Users\\86153\\AppData\\Local\\Google\\Chrome\\Application\\chromedriver.exe");
driver = new ChromeDriver();
driver.get("https://www.12306.cn/index/index.html");
driver.manage().window().maximize();
driver.manage().timeouts().implicitlyWait(10, TimeUnit.SECONDS);
}
\\ 请在这里插入JUnit5测试代码
@AfterEach
public void teardown() {
this.driver.quit();
}
private void takeScreenshot(String fileName) {
File screenshotFile = ((TakesScreenshot) driver).getScreenshotAs(OutputType.FILE);
try {
FileUtils.copyFile(screenshotFile, new File(fileName));
} catch (Exception e) {
e.printStackTrace();
}
}
}