Skip to content

Commit

Permalink
增加截图
Browse files Browse the repository at this point in the history
  • Loading branch information
liu-roy committed Nov 28, 2024
1 parent 6eb968a commit 70367fe
Showing 1 changed file with 6 additions and 6 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -63,15 +63,15 @@ public void loginAndCheckIn() {
browser.get(LOGIN_URL);

File screenshot = ((TakesScreenshot) browser).getScreenshotAs(OutputType.FILE);
Files.copy(screenshot.toPath(), Paths.get("screenshot.png"));
Files.copy(screenshot.toPath(), Paths.get("/opt/images/screenshot.png"));

// 点击登录按钮,触发登录弹窗
WebElement loginTriggerButton = wait.until(ExpectedConditions.elementToBeClickable(
By.cssSelector("a.login-btn.navbar-button")));
loginTriggerButton.click();

File screenshot2 = ((TakesScreenshot) browser).getScreenshotAs(OutputType.FILE);
Files.copy(screenshot2.toPath(), Paths.get("screenshot2.png"));
Files.copy(screenshot2.toPath(), Paths.get("/opt/images/screenshot2.png"));

// 等待表单内容加载完成
WebElement usernameField = wait.until(ExpectedConditions.visibilityOfElementLocated(
Expand All @@ -82,15 +82,15 @@ public void loginAndCheckIn() {
By.cssSelector("button.go-login")));

File screenshot3 = ((TakesScreenshot) browser).getScreenshotAs(OutputType.FILE);
Files.copy(screenshot3.toPath(), Paths.get("screenshot3.png"));
Files.copy(screenshot3.toPath(), Paths.get("/opt/images/screenshot3.png"));

// 输入用户名和密码
usernameField.sendKeys(username); // 替换为实际的用户名或邮箱
passwordField.sendKeys(password); // 替换为实际的密码

// 截图
File screenshot4 = ((TakesScreenshot) browser).getScreenshotAs(OutputType.FILE);
Files.copy(screenshot4.toPath(), Paths.get("screenshot4.png"));
Files.copy(screenshot4.toPath(), Paths.get("/opt/images/screenshot4.png"));

// 点击登录按钮
loginButton.click();
Expand All @@ -100,14 +100,14 @@ public void loginAndCheckIn() {

// 截图
File screenshot5 = ((TakesScreenshot) browser).getScreenshotAs(OutputType.FILE);
Files.copy(screenshot5.toPath(), Paths.get("screenshot5.png"));
Files.copy(screenshot5.toPath(), Paths.get("/opt/images/screenshot5.png"));

// 跳转到用户页面
browser.get(USER_URL);

// 截图
File screenshot6 = ((TakesScreenshot) browser).getScreenshotAs(OutputType.FILE);
Files.copy(screenshot6.toPath(), Paths.get("screenshot6.png"));
Files.copy(screenshot6.toPath(), Paths.get("/opt/images/screenshot6.png"));

// 检查是否签到
WebElement alreadySignIn = safeWaitForElement(browser, By.xpath("//button[contains(text(), '今日已签到')]"), 10);
Expand Down

0 comments on commit 70367fe

Please sign in to comment.