From 858ca63bbda000e47ba6dadba47897d66aef4081 Mon Sep 17 00:00:00 2001 From: zfh <15856818120@163.com> Date: Fri, 28 Feb 2025 16:30:10 +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 --- main/java/com/bonus/autoweb/TestMain.java | 2 - .../bonus/autoweb/base/DutyChangeShifts.java | 16 +++- .../com/bonus/autoweb/base/DutyClock.java | 33 ++++++- .../com/bonus/autoweb/base/DutyLogIOp.java | 20 ++++- pom.xml | 85 +++++++++++++++++++ 5 files changed, 148 insertions(+), 8 deletions(-) create mode 100644 pom.xml diff --git a/main/java/com/bonus/autoweb/TestMain.java b/main/java/com/bonus/autoweb/TestMain.java index 4cc5c48..6c9aa1f 100644 --- a/main/java/com/bonus/autoweb/TestMain.java +++ b/main/java/com/bonus/autoweb/TestMain.java @@ -1,7 +1,5 @@ package com.bonus.autoweb; -import cn.hutool.http.HttpRequest; -import cn.hutool.http.HttpUtil; import com.bonus.autoweb.UI.entity.WeatherData; import com.bonus.autoweb.base.DataConfig; import com.bonus.autoweb.task.AutoWebTask; diff --git a/main/java/com/bonus/autoweb/base/DutyChangeShifts.java b/main/java/com/bonus/autoweb/base/DutyChangeShifts.java index 6562f65..0f72001 100644 --- a/main/java/com/bonus/autoweb/base/DutyChangeShifts.java +++ b/main/java/com/bonus/autoweb/base/DutyChangeShifts.java @@ -70,8 +70,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("正常"); - log.info("交接事项说明----------"); + + 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); //提交 webDriver.findElement(By.xpath("/html/body/div[3]/div/div[3]/div/button[2]")).click(); @@ -175,4 +185,4 @@ public class DutyChangeShifts { } -} \ No newline at end of file +} diff --git a/main/java/com/bonus/autoweb/base/DutyClock.java b/main/java/com/bonus/autoweb/base/DutyClock.java index 41c5308..6f2edaa 100644 --- a/main/java/com/bonus/autoweb/base/DutyClock.java +++ b/main/java/com/bonus/autoweb/base/DutyClock.java @@ -69,9 +69,40 @@ public class DutyClock { log.info("打卡签到----------"); Thread.sleep(1000*5); + //判断是否有相应的元素 + try { + Thread.sleep(2000); + webDriver.findElement(By.xpath("html/body/div[2]/div/div[3]/button[2]")).click(); + log.info("确认提前签到div[2]----------"); + } catch (Exception e) { + log.info("无确认框,在时间范围内----------"); + } + + //判断是否有相应的元素 + try { + Thread.sleep(2000); + webDriver.findElement(By.xpath("html/body/div[6]/div/div[3]/button[2]")).click(); + log.info("确认提前签到div[6]----------"); + } catch (Exception e) { + log.info("无确认框,在时间范围内----------"); + } + + + try { + //点击弹出框确认 + webDriver.findElement(By.xpath("/html/body/div[2]/div/div[2]/div/div[2]/div[1]")).click(); + } catch (Exception e) { + log.info("当前打卡确认按钮不存在div[2]"); + } + try { + //点击弹出框确认 + webDriver.findElement(By.xpath("/html/body/div[3]/div/div[2]/div/div[2]/div[1]")).click(); + } catch (Exception e) { + log.info("当前打卡按钮不存在div[3]"); + } //点击弹出框确认 - webDriver.findElement(By.xpath("/html/body/div[2]/div/div[2]/div/div[2]/div[1]")).click(); + //webDriver.findElement(By.xpath("/html/body/div[2]/div/div[2]/div/div[2]/div[1]")).click(); log.info("点击弹出框确认----------"); Thread.sleep(800); } diff --git a/main/java/com/bonus/autoweb/base/DutyLogIOp.java b/main/java/com/bonus/autoweb/base/DutyLogIOp.java index 0a71f89..e8c8dd1 100644 --- a/main/java/com/bonus/autoweb/base/DutyLogIOp.java +++ b/main/java/com/bonus/autoweb/base/DutyLogIOp.java @@ -319,6 +319,22 @@ public class DutyLogIOp { log.info("提交日志----------"); Thread.sleep(300); + //判断是否有相应的元素 + try{ + Thread.sleep(2000); + webDriver.findElement(By.xpath("html/body/div[3]/div/div[3]/button[2]")).click(); + 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]")).click(); + log.info("是否确认签到----------"); + }catch (Exception e){ + log.info("无确认框,在时间范围内div[4]----------"); + } + //点击弹出框确认 WebElement qrBtn=webDriver.findElement(By.xpath("/html/body/div[4]/div/div[3]/button[2]")); @@ -341,14 +357,14 @@ public class DutyLogIOp { //退出当前iframe, webDriver.switchTo().defaultContent(); log.info("退出当前iframe----------"); - Thread.sleep(300); + Thread.sleep(3000); //定位值班管理iframe的标签 WebElement dutyIframe = webDriver.findElement(By.id("zbgln")); webDriver.switchTo().frame(dutyIframe); log.info("定位值班管理iframe的标签----------"); - Thread.sleep(300); + Thread.sleep(3000); } diff --git a/pom.xml b/pom.xml new file mode 100644 index 0000000..b7f5aa5 --- /dev/null +++ b/pom.xml @@ -0,0 +1,85 @@ + + + 4.0.0 + + autoWebForSiXian + autoWebForSiXian + 1.0-SNAPSHOT + + + + org.apache.maven.plugins + maven-compiler-plugin + + 8 + 8 + + + + + + + + org.seleniumhq.selenium + selenium-java + 3.141.59 + + + + + com.google.code.gson + gson + 2.2.4 + + + com.thoughtworks.xstream + xstream + 1.4.9 + + + org.codehaus.jettison + jettison + 1.3.7 + + + org.projectlombok + lombok + 1.18.26 + compile + + + + org.quartz-scheduler + quartz + 2.2.1 + + + + com.hynnet + jacob + 1.18 + + + + commons-logging + commons-logging-api + 1.1 + + + + org.slf4j + slf4j-api + 1.7.26 + + + + org.slf4j + slf4j-log4j12 + 1.7.26 + + + + +