From bab94a89ab06d9dc363326bf16be4df2708cd078 Mon Sep 17 00:00:00 2001 From: zfh <15856818120@163.com> Date: Fri, 28 Feb 2025 16:29:00 +0800 Subject: [PATCH] =?UTF-8?q?=E7=B3=BB=E7=BB=9F=E6=9B=B4=E6=96=B0?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../bonus/autoweb/base/DutyChangeShifts.java | 15 +++++++++++++-- .../java/com/bonus/autoweb/base/DutyClock.java | 18 ++++++++++++++++++ .../com/bonus/autoweb/base/DutyLogIOp.java | 16 ++++++++++++++++ 3 files changed, 47 insertions(+), 2 deletions(-) diff --git a/src/main/java/com/bonus/autoweb/base/DutyChangeShifts.java b/src/main/java/com/bonus/autoweb/base/DutyChangeShifts.java index fcbb099..f2c9c96 100644 --- a/src/main/java/com/bonus/autoweb/base/DutyChangeShifts.java +++ b/src/main/java/com/bonus/autoweb/base/DutyChangeShifts.java @@ -71,7 +71,18 @@ public class DutyChangeShifts { //交接事项说明 if (type == 1) { // /html/body/div[3]/div/div[2]/div/form/div[7]/div/div[1]/textarea - webDriver.findElement(By.xpath("/html/body/div[3]/div/div[2]/div/form/div[2]/div/div[1]/textarea")).sendKeys("正常"); +// webDriver.findElement(By.xpath("/html/body/div[3]/div/div[2]/div/form/div[2]/div/div[1]/textarea")).sendKeys("正常"); + try { + webDriver.findElement(By.xpath("/html/body/div[3]/div/div[2]/div/form/div[2]/div/div[1]/textarea")).sendKeys("正常"); + }catch (Exception e){ + log.info("交接事项说明div[3]不存在----------"); + } + + try { + webDriver.findElement(By.xpath("/html/body/div[8]/div/div[2]/div/form/div[2]/div/div[1]/textarea")).sendKeys("正常"); + }catch (Exception e){ + log.info("交接事项说明div[8]不存在----------"); + } log.info("交接事项说明----------"); Thread.sleep(500); //提交 @@ -347,4 +358,4 @@ public class DutyChangeShifts { // Thread.sleep(300); } -} \ No newline at end of file +} diff --git a/src/main/java/com/bonus/autoweb/base/DutyClock.java b/src/main/java/com/bonus/autoweb/base/DutyClock.java index 35001e9..116adb1 100644 --- a/src/main/java/com/bonus/autoweb/base/DutyClock.java +++ b/src/main/java/com/bonus/autoweb/base/DutyClock.java @@ -73,6 +73,24 @@ public class DutyClock { xpaht = "//*[@id=\"pane-2\"]/div/div[3]/div[2]/div[1]/div[2]/button[2]"; } } + + //判断是否有相应的元素 + try{ + Thread.sleep(2000); + webDriver.findElement(By.xpath("html/body/div[6]/div/div[3]/button[2]")); + log.info("是否确认签到----------"); + }catch (Exception e){ + log.info("无确认框,在时间范围内----------"); + } + //判断是否有相应的元素 + try{ + Thread.sleep(2000); + webDriver.findElement(By.xpath("html/body/div[2]/div/div[3]/button[2]")); + log.info("是否确认签到----------"); + }catch (Exception e){ + log.info("无确认框,在时间范围内----------"); + } + Thread.sleep(1000 * 4); webDriver.findElement(By.xpath(xpaht)).click(); log.info("打卡签到----------"); diff --git a/src/main/java/com/bonus/autoweb/base/DutyLogIOp.java b/src/main/java/com/bonus/autoweb/base/DutyLogIOp.java index 57bb5da..2f1d7b6 100644 --- a/src/main/java/com/bonus/autoweb/base/DutyLogIOp.java +++ b/src/main/java/com/bonus/autoweb/base/DutyLogIOp.java @@ -324,6 +324,22 @@ public class DutyLogIOp { log.info("提交日志----------"); Thread.sleep(500); + //判断是否有相应的元素 + try{ + Thread.sleep(2000); + webDriver.findElement(By.xpath("html/body/div[3]/div/div[3]/button[2]")); + log.info("是否确认签到----------"); + }catch (Exception e){ + log.info("无确认框,在时间范围内div[3]----------"); + } + try{ + Thread.sleep(2000); + webDriver.findElement(By.xpath("html/body/div[4]/div/div[3]/button[2]")); + log.info("是否确认签到----------"); + }catch (Exception e){ + log.info("无确认框,在时间范围内div[4]----------"); + } + //点击弹出框确认 WebElement qrBtn = webDriver.findElement(By.xpath("/html/body/div[4]/div/div[3]/button[2]"));