From b06f4a917e1befc045f1894c125bd44fcb7bd5fe Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E9=A9=AC=E4=B8=89=E7=82=AE?= <15856818120@163.com> Date: Mon, 11 Aug 2025 16:02:33 +0800 Subject: [PATCH] =?UTF-8?q?=E6=9B=B4=E6=96=B0=E7=B3=BB=E7=BB=9F?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../java/com/bonus/autoweb/GetBasicData.java | 8 +- .../java/com/bonus/autoweb/base/AutoMain.java | 88 +++++++++++++++---- .../com/bonus/autoweb/base/DutyLogIOp.java | 20 ++++- 3 files changed, 91 insertions(+), 25 deletions(-) diff --git a/src/main/java/com/bonus/autoweb/GetBasicData.java b/src/main/java/com/bonus/autoweb/GetBasicData.java index da14938..c365cdc 100644 --- a/src/main/java/com/bonus/autoweb/GetBasicData.java +++ b/src/main/java/com/bonus/autoweb/GetBasicData.java @@ -712,9 +712,9 @@ public class GetBasicData { logBean.setPower_work_content(data + logContentArrayArray[7]); logBean.setResource_check_title(logContentArrayArray[9]); logBean.setResource_check_content(data + checkContentArrayArray[num]); - logBean.setCommunications_test_title("今日开展通信测试1项,均正常"); + logBean.setCommunications_test_title("今日开展通信测试1项"); logBean.setCommunications_test_content(communicationTestName + ";" + logContentArrayArray[11]); - logBean.setDaily_operation_title("今日开展日常操练1次"); + logBean.setDaily_operation_title("今日开展队伍操练核查1项"); logBean.setDaily_operation_content(dailyExercisesName + ";" + logContentArrayArray[13]); logBean.setDaily_submission_title(logContentArrayArray[15]); logBean.setDaily_submission_content(data + logContentArrayArray[16]); @@ -791,9 +791,9 @@ public class GetBasicData { logBean.setPower_work_content(data + logContentArrayArray[7]); logBean.setResource_check_title(logContentArrayArray[9]); logBean.setResource_check_content(data + checkContentArrayArray[num]); - logBean.setCommunications_test_title("今日开展通信测试1项,均正常"); + logBean.setCommunications_test_title("今日开展通信测试1项"); logBean.setCommunications_test_content(communicationTestName + ";" + logContentArrayArray[11]); - logBean.setDaily_operation_title("今日开展日常操练1次"); + logBean.setDaily_operation_title("今日开展队伍操练核查1项"); logBean.setDaily_operation_content(dailyExercisesName + ";" + logContentArrayArray[13]); logBean.setDaily_submission_title(logContentArrayArray[15]); logBean.setDaily_submission_content(data + logContentArrayArray[16]); diff --git a/src/main/java/com/bonus/autoweb/base/AutoMain.java b/src/main/java/com/bonus/autoweb/base/AutoMain.java index 9637064..3dbe090 100644 --- a/src/main/java/com/bonus/autoweb/base/AutoMain.java +++ b/src/main/java/com/bonus/autoweb/base/AutoMain.java @@ -167,18 +167,33 @@ public class AutoMain { WebElement wegl = webDriver.findElement(By.xpath("//*[@id=\"app\"]/div/div[1]/div[6]/div/div/div[6]/span/span" + "/div")); action.moveToElement(wegl).build().perform(); - Thread.sleep(300); + Thread.sleep(1000); //获取管理标签中的aria-describedby属性 String attributeId = wegl.getAttribute("aria-describedby"); log.info("管理标签的ID值为:" + attributeId); - Thread.sleep(300); - //执行鼠标悬停动作-常态值班 - String ctzbXpath = "//*[@id=\"" + attributeId + "\"]/div/div[1]/div[2]/div[4]"; - WebElement wectzb = webDriver.findElement(By.xpath(ctzbXpath)); - action.moveToElement(wectzb).build().perform(); + //判断是否有相应的元素 + try { + Thread.sleep(1000); + //执行鼠标悬停动作-常态值班 + String ctzbXpath = "//*[@id=\"" + attributeId + "\"]/div/div[1]/div[2]/div[4]"; + WebElement wectzb = webDriver.findElement(By.xpath(ctzbXpath)); + action.moveToElement(wectzb).build().perform(); + } catch (Exception e) { + log.info("无确认框,在时间范围内----------常态值班"); + } + //判断是否有相应的元素 + try { + Thread.sleep(1000); + //执行鼠标悬停动作-常态值班 + String ctzbXpath = "//*[@id=\"" + attributeId + "\"]/div/div[1]/div/div[4]/div"; + WebElement wectzb = webDriver.findElement(By.xpath(ctzbXpath)); + action.moveToElement(wectzb).build().perform(); + } catch (Exception e) { + log.info("无确认框,在时间范围内----------"); + } Thread.sleep(300); @@ -229,9 +244,22 @@ public class AutoMain { //打开预警响应管理页面 - //*[@id=\"" + attributeId + "\"]/div/div[2]/div[2]/div[1]/div[2] - String zbglXpath = "//*[@id=\"" + attributeId + "\"]/div/div/div[2]/div[3]"; - webDriver.findElement(By.xpath(zbglXpath)).click(); + //判断是否有相应的元素 + try { + Thread.sleep(2000); + String zbglXpath = "//*[@id=\"" + attributeId + "\"]/div/div/div[2]/div[3]"; + webDriver.findElement(By.xpath(zbglXpath)).click(); + } catch (Exception e) { + log.info("无确认框,在时间范围内----------"); + } + //判断是否有相应的元素 + try { + Thread.sleep(2000); + String zbglXpath = "//*[@id=\"" + attributeId + "\"]/div/div/div/div[3]/div"; + webDriver.findElement(By.xpath(zbglXpath)).click(); + } catch (Exception e) { + log.info("无确认框,在时间范围内----------"); + } log.info("打开预警页面------------"); Thread.sleep(800); @@ -258,7 +286,7 @@ public class AutoMain { //获取管理标签中的aria-describedby属性 el-popover-7909 String attributeId = wegl.getAttribute("aria-describedby"); log.info("管理标签的ID值为:" + attributeId); - Thread.sleep(300); + Thread.sleep(2000); // //执行鼠标悬停动作-预警行动 @@ -297,16 +325,29 @@ public class AutoMain { WebElement wegl = webDriver.findElement(By.xpath("//*[@id=\"app\"]/div/div[1]/div[6]/div/div/div[6]/span/span" + "/div")); action.moveToElement(wegl).build().perform(); - Thread.sleep(300); + Thread.sleep(2000); //获取管理标签中的aria-describedby属性 String attributeId = wegl.getAttribute("aria-describedby"); log.info("管理标签的ID值为:" + attributeId); - Thread.sleep(300); + Thread.sleep(2000); //执行鼠标悬停动作-检查操练管理 - String ctzbXpath = "//*[@id=\"" + attributeId + "\"]/div/div[1]/div[2]/div[5]"; - webDriver.findElement(By.xpath(ctzbXpath)).click(); + //判断是否有相应的元素 + try { + Thread.sleep(2000); + String ctzbXpath = "//*[@id=\"" + attributeId + "\"]/div/div[1]/div[2]/div[5]"; + webDriver.findElement(By.xpath(ctzbXpath)).click(); + } catch (Exception e) { + log.info("无确认框,在时间范围内----------"); + } + try { + Thread.sleep(2000); + String ctzbXpath = "//*[@id=\"" + attributeId + "\"]/div/div/div/div[5]/div"; + webDriver.findElement(By.xpath(ctzbXpath)).click(); + } catch (Exception e) { + log.info("无确认框,在时间范围内----------"); + } // WebElement wectzb = // action.moveToElement(wectzb).build().perform(); // Thread.sleep(300); @@ -361,7 +402,7 @@ public class AutoMain { WebElement wegl = webDriver.findElement(By.xpath("//*[@id=\"app\"]/div/div[1]/div[6]/div/div/div[6]/span/span" + "/div")); action.moveToElement(wegl).build().perform(); - Thread.sleep(300); + Thread.sleep(2000); //获取管理标签中的aria-describedby属性 String attributeId = wegl.getAttribute("aria-describedby"); @@ -369,8 +410,21 @@ public class AutoMain { Thread.sleep(300); //执行鼠标悬停动作-检查操练管理 - String ctzbXpath = "//*[@id=\"" + attributeId + "\"]/div/div[1]/div[2]/div[5]"; - webDriver.findElement(By.xpath(ctzbXpath)).click(); + try { + Thread.sleep(2000); + String ctzbXpath = "//*[@id=\"" + attributeId + "\"]/div/div[1]/div[2]/div[5]"; + webDriver.findElement(By.xpath(ctzbXpath)).click(); + } catch (Exception e) { + log.info("无确认框,在时间范围内----------"); + } + //判断是否有相应的元素 + try { + Thread.sleep(2000); + String ctzbXpath = "//*[@id=\"" + attributeId + "\"]/div/div/div/div[5]/div"; + webDriver.findElement(By.xpath(ctzbXpath)).click(); + } catch (Exception e) { + log.info("无确认框,在时间范围内----------"); + } // WebElement wectzb = // action.moveToElement(wectzb).build().perform(); // Thread.sleep(300); diff --git a/src/main/java/com/bonus/autoweb/base/DutyLogIOp.java b/src/main/java/com/bonus/autoweb/base/DutyLogIOp.java index cb7e828..4d31e2a 100644 --- a/src/main/java/com/bonus/autoweb/base/DutyLogIOp.java +++ b/src/main/java/com/bonus/autoweb/base/DutyLogIOp.java @@ -49,10 +49,22 @@ public class DutyLogIOp { // /html/body/div[2] 弹窗 您没有填写值班日志的排班班次 //定位写日志标签,打开日志页面 - webDriver.findElement(By.xpath("//*[@id=\"pane-5\"]/div/div[2]/div[2]/button")).click(); - log.info("定位写日志标签,打开日志页面----------"); - Thread.sleep(1500); - + try { + //定位写日志标签,打开日志页面 + webDriver.findElement(By.xpath("//*[@id=\"pane-5\"]/div/div[2]/div[2]/button")).click(); + log.info("定位写日志标签,打开日志页面----------/div/div[2]/div[2]/button"); + Thread.sleep(1500); + } catch (Exception e) { + log.info("无确认框,在时间范围内----------"); + } + try { + //定位写日志标签,打开日志页面 + webDriver.findElement(By.xpath("//*[@id=\"pane-5\"]/div/div[2]/div[2]/button/span")).click(); + log.info("定位写日志标签,打开日志页面----------"); + Thread.sleep(1500); + } catch (Exception e) { + log.info("无确认框,在时间范围内----------/div/div[2]/div[2]/button/span"); + } //退出当前iframe,进入到日报编辑iframe webDriver.switchTo().defaultContent();