Skip to content

Commit

Permalink
删除屏幕截图
Browse files Browse the repository at this point in the history
  • Loading branch information
liu-roy committed Nov 30, 2024
1 parent e0e2e90 commit 8eab5ae
Showing 1 changed file with 2 additions and 18 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -64,16 +64,14 @@ public void loginAndCheckIn() {
WebDriverWait wait = new WebDriverWait(browser, 10); //
browser.get(LOGIN_URL);

File screenshot = ((TakesScreenshot) browser).getScreenshotAs(OutputType.FILE);
Files.copy(screenshot.toPath(), Paths.get("/opt/images/screenshot.png"));
// File screenshot = ((TakesScreenshot) browser).getScreenshotAs(OutputType.FILE);
// 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("/opt/images/screenshot2.png"));

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

File screenshot3 = ((TakesScreenshot) browser).getScreenshotAs(OutputType.FILE);
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("/opt/images/screenshot4.png"));

// 点击登录按钮
loginButton.click();

// 等待登录完成后的页面标志(比如跳转或特定元素出现)
waitForAjaxLoad(browser);

// 截图
File screenshot5 = ((TakesScreenshot) browser).getScreenshotAs(OutputType.FILE);
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("/opt/images/screenshot6.png"));

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

0 comments on commit 8eab5ae

Please sign in to comment.