From 2bfd39c95348f5e91f67b3573d3ccc0971b46fda Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E5=8C=97=E9=A3=8E?= <2452618307@qq.com> Date: Wed, 21 Feb 2024 09:21:29 +0800 Subject: [PATCH] =?UTF-8?q?=E7=AD=BE=E9=80=80=E4=BA=BA=E5=91=98=E8=A6=86?= =?UTF-8?q?=E7=9B=96=E6=95=B0=E6=8D=AE=E4=BC=98=E5=8C=96=20=E6=B7=BB?= =?UTF-8?q?=E5=8A=A0=E5=A4=A9=E6=B0=94,=E6=9C=80=E9=AB=98=E6=B8=A9?= =?UTF-8?q?=E5=BA=A6,=E6=9C=80=E4=BD=8E=E6=B8=A9=E5=BA=A6=E6=95=B0?= =?UTF-8?q?=E6=8D=AE=E4=B8=8A=E6=8A=A5=20=E7=AD=89?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../java/com/bonus/autoweb/GetBasicData.java | 280 ++++++++++-------- src/main/java/com/bonus/autoweb/TestMain.java | 96 +++--- .../java/com/bonus/autoweb/base/AutoMain.java | 48 +-- .../com/bonus/autoweb/base/DutyDailyOp.java | 114 +++---- .../com/bonus/autoweb/base/DutyLogIOp.java | 49 +-- .../com/bonus/autoweb/task/AutoWebTask.java | 2 + 6 files changed, 329 insertions(+), 260 deletions(-) diff --git a/src/main/java/com/bonus/autoweb/GetBasicData.java b/src/main/java/com/bonus/autoweb/GetBasicData.java index 74c9372..c1e108b 100644 --- a/src/main/java/com/bonus/autoweb/GetBasicData.java +++ b/src/main/java/com/bonus/autoweb/GetBasicData.java @@ -310,7 +310,7 @@ public class GetBasicData { //判断是否有发布数据 WebElement numClasses = webDriver.findElement(By.xpath("//*[@id=\"tab-3\"]/div/span")); if ("0".equals(numClasses.getText())) { - code = "亳州市未发布预警,"; + code = "蒙城县未发布预警,"; } else { WebElement weatherEle = webDriver.findElement(By.xpath("/html/body/div[1]/div/section/main/div[1]/div[2]/div[1]/section/main/div/div[3]/table/tbody/tr[1]/td[6]/div/div")); Thread.sleep(300); @@ -330,7 +330,7 @@ public class GetBasicData { Date date1 = inputFormat.parse(endTime); SimpleDateFormat outputFormat = new SimpleDateFormat("MM月dd日"); - code = "亳州及所属三县公司同步发布" + weatherEle.getText() + "预警各1项,"; + code = "蒙城县供电公司发布" + weatherEle.getText() + "预警1项,"; } log.info("code:" + code); @@ -352,23 +352,23 @@ public class GetBasicData { //明天的日期 String data3 = DateTimeUtils.getTomorrowDate(); //日志时间 - String logData = data2 + "08:30至" + data3 + "8:30,"; + String logData = data2 + "08:15至" + data3 + "8:15,"; //日报时间 String data = ""; if (classes == 1) { - data = data2 + "17:30至" + data3 + "08:30,"; + data = data2 + "18:00至" + data3 + "07:00,"; //一、总体情况 dailyBean.setOverall(data + dailyContentArrayArray[2].trim()); dailyBean.setWarning_company(code + dailyContentArrayArray[19]); } else { - data = data2 + "08:30至" + data2 + "17:30,"; + data = data2 + "07:00至" + data2 + "18:00,"; dailyBean2.setOverall(data + dailyContentArrayArray[2].trim()); dailyBean2.setWarning_company(code + dailyContentArrayArray[19]); } - logBean.setWarning_disposal_title("亳州市未发布预警,".equals(code) ? "今日预警情况" : "预警四项"); + logBean.setWarning_disposal_title("蒙城县未发布预警,".equals(code) ? "今日预警情况" : "预警一项"); logBean.setWarning_disposal_content(logData + code + logContentArrayArray[20]); insertData(null, logBean, "log"); log.info("天气预警日志更新完成"); @@ -401,7 +401,7 @@ public class GetBasicData { String data3 = DateTimeUtils.getTomorrowDate(); log.info("明天的日期:" + data2); //日志时间 - String logData = data2 + "08:30至" + data3 + "8:30,"; + String logData = data2 + "08:15至" + data3 + "8:15,"; /** * 获取指定位置标签的值 */ @@ -424,130 +424,130 @@ public class GetBasicData { time = DateTimeUtils.getCurrentDay(); } - webDriver.findElement(By.xpath("/html/body/div/div/header/form/div[4]/div/button[1]")).click(); - Thread.sleep(800); - webDriver.findElement(By.xpath("/html/body/div[1]/div/header/form/div[6]/div/div/input[1]")).sendKeys(DateTimeUtils.getCurrentDay()); - Thread.sleep(800); - webDriver.findElement(By.xpath("/html/body/div[1]/div/header/form/div[6]/div/div/input[2]")).sendKeys(DateTimeUtils.getCurrentDay()); - Thread.sleep(800); - webDriver.findElement(By.xpath("/html/body/div[1]/div/header/form/div[8]/div/button[2]")).click(); - Thread.sleep(2000); - int i = 1; - while (tf) { - Thread.sleep(10000); - WebElement numberEle = webDriver.findElement(By.xpath("/html/body/div[1]/div/main/div/div/footer/span")); - log.info("numberEle:" + numberEle.getText()); -// String num = numberEle.getText().substring(2, 3); - String num1 = numberEle.getText().substring(2, numberEle.getText().length()); - String num = num1.substring(0, num1.length() - 2); - log.info("num:" + num); - if ("0".equals(num)) { - tf = false; - } else { - WebElement timeEle; -// if ("1".equals(num)) { -// timeEle = webDriver.findElement(By.xpath("/html/body/div/div/main/div/div/div[2]/div/div[3]/table/tbody/tr/td[8]/div")); +// webDriver.findElement(By.xpath("/html/body/div/div/header/form/div[4]/div/button[1]")).click(); +// Thread.sleep(800); +// webDriver.findElement(By.xpath("/html/body/div[1]/div/header/form/div[6]/div/div/input[1]")).sendKeys(DateTimeUtils.getCurrentDay()); +// Thread.sleep(800); +// webDriver.findElement(By.xpath("/html/body/div[1]/div/header/form/div[6]/div/div/input[2]")).sendKeys(DateTimeUtils.getCurrentDay()); +// Thread.sleep(800); +// webDriver.findElement(By.xpath("/html/body/div[1]/div/header/form/div[8]/div/button[2]")).click(); +// Thread.sleep(2000); +// int i = 1; +// while (tf) { +// Thread.sleep(10000); +// WebElement numberEle = webDriver.findElement(By.xpath("/html/body/div[1]/div/main/div/div/footer/span")); +// log.info("numberEle:" + numberEle.getText()); +//// String num = numberEle.getText().substring(2, 3); +// String num1 = numberEle.getText().substring(2, numberEle.getText().length()); +// String num = num1.substring(0, num1.length() - 2); +// log.info("num:" + num); +// if ("0".equals(num)) { +// tf = false; +// } else { +// WebElement timeEle; +//// if ("1".equals(num)) { +//// timeEle = webDriver.findElement(By.xpath("/html/body/div/div/main/div/div/div[2]/div/div[3]/table/tbody/tr/td[8]/div")); +//// } else { +// timeEle = webDriver.findElement(By.xpath("/html/body/div[1]/div/main/div/div/div[2]/div/div[3" + +// "]/table/tbody/tr[" + i + "]/td[8]/div")); +//// } +// +// System.out.println(timeEle.getText()); +// if (time.equals(timeEle.getText())) { +// //操练环节 -通信测试 日常操练 +// WebElement drillSessionEle; +//// if ("1".equals(num)) { +//// drillSessionEle = webDriver.findElement(By.xpath("/html/body/div/div/main/div/div/div[2]/div/div[3]/table/tbody/tr/td[6]/div")); +//// } else { +// drillSessionEle = webDriver.findElement(By.xpath("/html/body/div[1]/div/main/div/div/div[2" + +// "]/div/div[3]/table/tbody/tr[" + i + "]/td[6]/div")); +//// } +// log.info("操练环节:" + drillSessionEle.getText()); +// //供电公司 +// WebElement powerSupplyCompaniesEle; +//// if ("1".equals(num)) { +//// powerSupplyCompaniesEle = webDriver.findElement(By.xpath("/html/body/div/div/main/div/div/div[2]/div/div[3]/table/tbody/tr/td[5]/div")); +//// } else { +// powerSupplyCompaniesEle = webDriver.findElement(By.xpath("/html/body/div[1]/div/main/div/div" + +// "/div[2]/div/div[3]/table/tbody/tr[" + i + "]/td[5]/div")); +//// } +// log.info("供电公司:" + powerSupplyCompaniesEle.getText()); +// if ("通信测试".equals(drillSessionEle.getText())) { +// communicationTestNum++; +// communicationTestName1 += getDailyName(powerSupplyCompaniesEle.getText()) + "、"; +// } else if ("重要站线视频连线检查".equals(drillSessionEle.getText())) { +// dailyExercisesNum++; +//// dailyExercisesName1 += powerSupplyCompaniesEle.getText().substring(0, powerSupplyCompaniesEle.getText().length() - 4) + "、"; +// dailyExercisesName1 += getDailyName(powerSupplyCompaniesEle.getText()) + "、"; +// } else { +// dailyExercisesNum++; +//// dailyExercisesName2 += powerSupplyCompaniesEle.getText().substring(0, powerSupplyCompaniesEle.getText().length() - 4) + "、"; +// WebElement ele = webDriver.findElement(By.xpath("/html/body/div[1]/div/main/div/div/div[2" + +// "]/div/div[3]/table/tbody/tr[" + i + "]/td[7]/div")); +// if ("物资".equals(ele.getText())) +// materialName += getDailyName(powerSupplyCompaniesEle.getText()) + "、"; +// if ("车辆".equals(ele.getText())) +// carName += getDailyName(powerSupplyCompaniesEle.getText()) + "、"; +// if ("队伍".equals(ele.getText())) +// contingentName += getDailyName(powerSupplyCompaniesEle.getText()) + "、"; +// dailyExercisesName2 += getDailyName(powerSupplyCompaniesEle.getText()) + "、"; +// } +// int x = parseInt(num); +// if (i == parseInt(num)) { +// tf = false; +// } +// i++; // } else { - timeEle = webDriver.findElement(By.xpath("/html/body/div[1]/div/main/div/div/div[2]/div/div[3" + - "]/table/tbody/tr[" + i + "]/td[8]/div")); +// tf = false; // } - - System.out.println(timeEle.getText()); - if (time.equals(timeEle.getText())) { - //操练环节 -通信测试 日常操练 - WebElement drillSessionEle; -// if ("1".equals(num)) { -// drillSessionEle = webDriver.findElement(By.xpath("/html/body/div/div/main/div/div/div[2]/div/div[3]/table/tbody/tr/td[6]/div")); -// } else { - drillSessionEle = webDriver.findElement(By.xpath("/html/body/div[1]/div/main/div/div/div[2" + - "]/div/div[3]/table/tbody/tr[" + i + "]/td[6]/div")); -// } - log.info("操练环节:" + drillSessionEle.getText()); - //供电公司 - WebElement powerSupplyCompaniesEle; -// if ("1".equals(num)) { -// powerSupplyCompaniesEle = webDriver.findElement(By.xpath("/html/body/div/div/main/div/div/div[2]/div/div[3]/table/tbody/tr/td[5]/div")); -// } else { - powerSupplyCompaniesEle = webDriver.findElement(By.xpath("/html/body/div[1]/div/main/div/div" + - "/div[2]/div/div[3]/table/tbody/tr[" + i + "]/td[5]/div")); -// } - log.info("供电公司:" + powerSupplyCompaniesEle.getText()); - if ("通信测试".equals(drillSessionEle.getText())) { - communicationTestNum++; - communicationTestName1 += getDailyName(powerSupplyCompaniesEle.getText()) + "、"; - } else if ("重要站线视频连线检查".equals(drillSessionEle.getText())) { - dailyExercisesNum++; -// dailyExercisesName1 += powerSupplyCompaniesEle.getText().substring(0, powerSupplyCompaniesEle.getText().length() - 4) + "、"; - dailyExercisesName1 += getDailyName(powerSupplyCompaniesEle.getText()) + "、"; - } else { - dailyExercisesNum++; -// dailyExercisesName2 += powerSupplyCompaniesEle.getText().substring(0, powerSupplyCompaniesEle.getText().length() - 4) + "、"; - WebElement ele = webDriver.findElement(By.xpath("/html/body/div[1]/div/main/div/div/div[2" + - "]/div/div[3]/table/tbody/tr[" + i + "]/td[7]/div")); - if ("物资".equals(ele.getText())) - materialName += getDailyName(powerSupplyCompaniesEle.getText()) + "、"; - if ("车辆".equals(ele.getText())) - carName += getDailyName(powerSupplyCompaniesEle.getText()) + "、"; - if ("队伍".equals(ele.getText())) - contingentName += getDailyName(powerSupplyCompaniesEle.getText()) + "、"; - dailyExercisesName2 += getDailyName(powerSupplyCompaniesEle.getText()) + "、"; - } - int x = parseInt(num); - if (i == parseInt(num)) { - tf = false; - } - i++; - } else { - tf = false; - } - } - } - log.info("communicationTestName1:" + communicationTestName1); - if (communicationTestNum > 0) { - communicationTestName = "今日市公司本部对所属" + communicationTestNum + "家县公司(" + communicationTestName1.substring(0, communicationTestName1.length() - 1) + ")进行通信测试"; - } else { - communicationTestName = "今日市公司本部对所属县公司无通信测试"; - } - if (dailyExercisesName1.length() > 0) { - dailyExercisesName1 = dailyExercisesName1.substring(0, dailyExercisesName1.length() - 1); - } - if (dailyExercisesName2.length() > 0) { - dailyExercisesName2 = dailyExercisesName2.substring(0, dailyExercisesName2.length() - 1); - } - String fourElementVerification = ""; - if (materialName.length() > 0) { - materialName = materialName.substring(0, materialName.length() - 1); - fourElementVerification += materialName + "公司四要素物资核查、"; - } - if (carName.length() > 0) { - carName = carName.substring(0, carName.length() - 1); - fourElementVerification += carName + "公司四要素车辆核查、"; - } - if (contingentName.length() > 0) { - contingentName = contingentName.substring(0, contingentName.length() - 1); - fourElementVerification += contingentName + "公司四要素队伍核查、"; - } - if (dailyExercisesName1.length() > 0 && dailyExercisesName2.length() > 0) { - dailyExercisesName = "今日市公司本部对所属" + dailyExercisesNum + "家县公司进行日常操练(" + fourElementVerification + dailyExercisesName1 + "公司重要站连线检查)"; - } else if (dailyExercisesName1.length() == 0 && dailyExercisesName2.length() > 0) { - dailyExercisesName = "今日市公司本部对所属" + dailyExercisesNum + "家县公司进行日常操练(" + fourElementVerification + ")"; - } else if (dailyExercisesName1.length() > 0 && fourElementVerification.length() == 0) { - dailyExercisesName = "今日市公司本部对所属" + dailyExercisesNum + "家县公司进行日常操练(" + dailyExercisesName1 + "公司重要站连线检查)"; - } else { - dailyExercisesName = "今日市公司本部对所属" + dailyExercisesNum + "家县公司进行日常操练"; - } -// dailyExercisesName = "今日市公司本部对所属" + 0 + "家县公司进行日常操练"; - log.info("communicationTestName:" + communicationTestName); - log.info("dailyExercisesName:" + dailyExercisesName); - log.info("communicationTestNum:" + communicationTestNum); - log.info("dailyExercisesNum:" + dailyExercisesNum); +// } +// } +// log.info("communicationTestName1:" + communicationTestName1); +// if (communicationTestNum > 0) { +// communicationTestName = "今日市公司本部对所属" + communicationTestNum + "家县公司(" + communicationTestName1.substring(0, communicationTestName1.length() - 1) + ")进行通信测试"; +// } else { +// communicationTestName = "今日市公司本部对所属县公司无通信测试"; +// } +// if (dailyExercisesName1.length() > 0) { +// dailyExercisesName1 = dailyExercisesName1.substring(0, dailyExercisesName1.length() - 1); +// } +// if (dailyExercisesName2.length() > 0) { +// dailyExercisesName2 = dailyExercisesName2.substring(0, dailyExercisesName2.length() - 1); +// } +// String fourElementVerification = ""; +// if (materialName.length() > 0) { +// materialName = materialName.substring(0, materialName.length() - 1); +// fourElementVerification += materialName + "公司四要素物资核查、"; +// } +// if (carName.length() > 0) { +// carName = carName.substring(0, carName.length() - 1); +// fourElementVerification += carName + "公司四要素车辆核查、"; +// } +// if (contingentName.length() > 0) { +// contingentName = contingentName.substring(0, contingentName.length() - 1); +// fourElementVerification += contingentName + "公司四要素队伍核查、"; +// } +// if (dailyExercisesName1.length() > 0 && dailyExercisesName2.length() > 0) { +// dailyExercisesName = "今日市公司本部对所属" + dailyExercisesNum + "家县公司进行日常操练(" + fourElementVerification + dailyExercisesName1 + "公司重要站连线检查)"; +// } else if (dailyExercisesName1.length() == 0 && dailyExercisesName2.length() > 0) { +// dailyExercisesName = "今日市公司本部对所属" + dailyExercisesNum + "家县公司进行日常操练(" + fourElementVerification + ")"; +// } else if (dailyExercisesName1.length() > 0 && fourElementVerification.length() == 0) { +// dailyExercisesName = "今日市公司本部对所属" + dailyExercisesNum + "家县公司进行日常操练(" + dailyExercisesName1 + "公司重要站连线检查)"; +// } else { +// dailyExercisesName = "今日市公司本部对所属" + dailyExercisesNum + "家县公司进行日常操练"; +// } +//// dailyExercisesName = "今日市公司本部对所属" + 0 + "家县公司进行日常操练"; +// log.info("communicationTestName:" + communicationTestName); +// log.info("dailyExercisesName:" + dailyExercisesName); +// log.info("communicationTestNum:" + communicationTestNum); +// log.info("dailyExercisesNum:" + dailyExercisesNum); String type = ""; if (classes == 1) { type = "morning_daily"; //早报 boolean t = true; int num = getRandom(1, 3); - String data = data2 + "17:30至" + data3 + "08:30,"; + String data = data2 + "18:00至" + data3 + "07:00,"; //二、重要事项 dailyBean.setImportant_matters(data + dailyContentArrayArray[4].trim()); @@ -607,7 +607,7 @@ public class GetBasicData { //晚报 boolean t = true; int num = getRandom(1, 3); - String data = data2 + "08:30至" + data2 + "17:30,"; + String data = data2 + "07:00至" + data2 + "18:00,"; //一、总体情况 // dailyBean2.setOverall(data + dailyContentArrayArray[2].trim() + data2 + "17:30," + dailyContentArrayArray[3].trim()); //二、重要事项 @@ -1077,7 +1077,7 @@ public class GetBasicData { // String projectName = "通信"; //执行计划 // try { - executePlan(type, company, ""); + executePlan(type, company, "", code); // }catch (Exception e){ // while (true){ // WebElement webElement = webDriver.findElement(By.xpath("/html/body/div/div/div/div[2]/div[1]/section/div/section/section/div/div[3]/table/tbody/tr[1]/td[9]/div")); @@ -1088,7 +1088,7 @@ public class GetBasicData { // } } - private void executePlan(String type, String company, String projectName) throws InterruptedException { + private void executePlan(String type, String company, String projectName,int code) throws InterruptedException { Thread.sleep(2000); String checkContent = resolveGarbledCode("E:\\bns\\config\\检查计划评价.txt"); String[] checkContentArrayArray = checkContent.split("检查评价:"); @@ -1109,8 +1109,26 @@ public class GetBasicData { //填写项目评价 String appraise = ""; if("日常操练".equals(type)){ - webDriver.findElement(By.xpath("/html/body/div/section/main/header/div/div[1]/div/div/div/div[4]")).click(); - appraise = checkContentArrayArray[3].trim(); + if (code > 1){ + if (code == 2){ + //装备 + appraise = checkContentArrayArray[1].trim(); + webDriver.findElement(By.xpath("/html/body/div[1]/section/main/section/header/div/div/div")).click(); + Thread.sleep(1000); + webDriver.findElement(By.xpath("/html/body/div[2]/div[1]/div[1]/ul/li")).click(); + Thread.sleep(1000); + } + if (code == 3){ + //车辆 + appraise = checkContentArrayArray[2].trim(); + } + webDriver.findElement(By.xpath("/html/body/div/section/main/header/div/div[1]/div/div/div/div[3]")).click(); + }else { + webDriver.findElement(By.xpath("/html/body/div/section/main/header/div/div[1]/div/div/div/div[4]")).click(); + appraise = checkContentArrayArray[3].trim(); + } + + }else{ webDriver.findElement(By.xpath("/html/body/div/section/main/header/div/div[1]/div/div/div/div[3]")).click(); appraise = checkContentArrayArray[4].trim(); @@ -1208,14 +1226,14 @@ public class GetBasicData { webDriver.findElement(By.xpath("/html/body/div[3]/div/div[2]/section/header/form/div/div[3]/div/div[2]")).click(); log.info("点击检查操练项目选择框-----------"); Thread.sleep(1000); - webDriver.findElement(By.xpath("/html/body/div[5]/div[1]/div[1]/ul/li[1]")).click(); + webDriver.findElement(By.xpath("/html/body/div[5]/div[1]/div[1]/ul/li["+code+"]")).click(); log.info("选择操作内容----------"); Thread.sleep(1000); //选择被检查单位 webDriver.findElement(By.xpath("/html/body/div[3]/div/div[2]/section/header/form/div/div[4]/div/div[2]")).click(); log.info("点击选择被检查单位型选择框-----------"); Thread.sleep(1000); - webDriver.findElement(By.xpath("/html/body/div[6]/div[1]/div/div/div[1]/div[2]/div["+code+"]/div/span[2]")).click(); + webDriver.findElement(By.xpath("/html/body/div[6]/div[1]/div/div/div[1]/div[1]/span[2]")).click(); log.info("选择被检查单位----------"); Thread.sleep(500); //选择被检查对象 @@ -1229,7 +1247,7 @@ public class GetBasicData { "/tr[2]")).click(); Thread.sleep(1000); }else { - for (int i = 1; i < 9; i++) { + for (int i = 1; i < 3; i++) { webDriver.findElement(By.xpath("/html/body/div[7]/div/div[2]/section/section/main/div/div[3]/table" + "/tbody/tr["+i+"]")).click(); Thread.sleep(1000); diff --git a/src/main/java/com/bonus/autoweb/TestMain.java b/src/main/java/com/bonus/autoweb/TestMain.java index 69b11e5..b815d92 100644 --- a/src/main/java/com/bonus/autoweb/TestMain.java +++ b/src/main/java/com/bonus/autoweb/TestMain.java @@ -97,18 +97,19 @@ public class TestMain { // 应急值班账号 String emergencyPerson = content.toString().split(";")[0].split(":")[1]; String emergencyPersonPassword = content.toString().split(";")[1].split(":")[1]; - String[] array = {"蒙城","利辛","涡阳"}; - Random random = new Random(); - int index = random.nextInt(array.length); - log.info("随机值为:" + index); - log.info("随机值为:" + array[index]); - Thread.sleep(2000); - autoWebTask.addExercisePlan("通信测试", array[index], index+1, emergencyPerson, +// autoWebTask.addExercisePlan("通信测试", "", 1, emergencyPerson, +// emergencyPersonPassword); +// Thread.sleep(5000); +// autoWebTask.addExercisePlan("日常操练", "", 1, emergencyPerson, +// emergencyPersonPassword); +// Thread.sleep(5000); +// autoWebTask.addExercisePlan("日常操练", "", 2, emergencyPerson, +// emergencyPersonPassword); +// Thread.sleep(5000); + autoWebTask.addExercisePlan("日常操练", "", 2, emergencyPerson, emergencyPersonPassword); - Thread.sleep(1000 * 700); - autoWebTask.addExercisePlan("日常操练", array[index], index+1, emergencyPerson, - emergencyPersonPassword); - Thread.sleep(2000); +// autoWebTask.addExercisePlan("日常操练", "", 0, emergencyPerson, emergencyPersonPassword); +// Thread.sleep(2000); } //自动获取数据测试 @@ -139,7 +140,15 @@ public class TestMain { //操作日报 //日报审核工作 AutoWebTask autoWebTask = new AutoWebTask(); - autoWebTask.dutyAddDailyLogsTask(1,DataConfig.USER_NAME4,DataConfig.PASS4); + String content = GetBasicData.resolveGarbledCode("E:\\bns\\config\\值班账号.txt"); + System.out.println(content); + // 应急值班账号 + String emergencyPerson = content.toString().split(";")[0].split(":")[1]; + System.out.println(content); + String emergencyPersonPassword = content.toString().split(";")[1].split(":")[1]; + System.out.println(content); + Thread.sleep(2000); + autoWebTask.dutyAddDailyLogsTask(2,emergencyPerson,emergencyPersonPassword); Thread.sleep(1000); } catch (Exception e) { e.printStackTrace(); @@ -152,7 +161,12 @@ public class TestMain { try { //操作日志 AutoWebTask autoWebTask = new AutoWebTask(); - autoWebTask.dutyAddLogsTask(2,DataConfig.USER_NAME1,DataConfig.PASS1); + String content = GetBasicData.resolveGarbledCode("E:\\bns\\config\\值班账号.txt"); + // 应急值班账号 + String emergencyPerson = content.toString().split(";")[0].split(":")[1]; + String emergencyPersonPassword = content.toString().split(";")[1].split(":")[1]; + Thread.sleep(2000); + autoWebTask.dutyAddLogsTask(2,emergencyPerson,emergencyPersonPassword); count = 1; Thread.sleep(1000); log.info("count",count); @@ -169,7 +183,7 @@ public class TestMain { * * @throws Exception */ - private void autoJob() throws InterruptedException { + private void autoJob() throws InterruptedException, IOException { AutoWebTask autoWebTask = new AutoWebTask(); int logGatherCount = 0; @@ -215,7 +229,7 @@ public class TestMain { String yesterdaySignOutPerson = yesterdayContent.toString().split(";")[0].split(":")[1]; String yesterdaySignOutPersonPassword = yesterdayContent.toString().split(";")[1].split(":")[1]; - if(DateTimeUtils.isEffectiveDate("17:46", "17:55")){ + if(DateTimeUtils.isEffectiveDate("17:26", "17:55")){ //进行日报信息系统采集及获取工作 try { if (logGatherCount == 0){ @@ -238,10 +252,10 @@ public class TestMain { } catch (IOException e) { log.error("更新早上打卡人员", e); } - }else if (DateTimeUtils.isEffectiveDate("06:00", "06:30")) { + }else if (DateTimeUtils.isEffectiveDate("06:00", "06:15")) { //自动完成当值值班日报(早报)填写上报 if (dailyzao == 0) { - getTime(1100); + getTime(600); try { dailyzao = autoWebTask.dutyAddDailyLogsTask(1,emergencyPerson,emergencyPersonPassword); @@ -250,7 +264,7 @@ public class TestMain { log.error("日报工作", e); } } - }else if (DateTimeUtils.isEffectiveDate("06:31", "06:50")) { + }else if (DateTimeUtils.isEffectiveDate("06:16", "06:30")) { //完成值班日志填写提交(晚班日志,此次值班日志为总结前一天晚上的情况) if (logzao == 0) { getTime(600); @@ -260,13 +274,13 @@ public class TestMain { log.error("日志工作", e); } } - }else if (DateTimeUtils.isEffectiveDate("07:20", "07:50")) { + }else if (DateTimeUtils.isEffectiveDate("07:05", "07:30")) { //自动完成当值值班签到(值班主任、值班人员都要签到) if ("error".equals(content)) { log.error("读取打卡人员数据错误"); }else { if (signInzao == 0 && signInzao2 == 0){ - getTime(1100); + getTime(900); } if (signInzao == 0) { log.info("应急值班账号开始打卡任务---------------------"); @@ -294,7 +308,7 @@ public class TestMain { } } } - }else if (DateTimeUtils.isEffectiveDate("08:05", "08:20")) { + }else if (DateTimeUtils.isEffectiveDate("07:35", "08:00")) { if (jjbzao == 0 && jjbzao2 == 0){ getTime(600); } @@ -311,9 +325,9 @@ public class TestMain { log.error("接接班任务", e); } } - }else if (DateTimeUtils.isEffectiveDate("08:35", "09:00")) { + }else if (DateTimeUtils.isEffectiveDate("08:20", "08:40")) { if(signOutzao == 0 && signOutzao2 == 0){ - getTime(1100); + getTime(900); } //自动在系统内完成签退 try { @@ -332,11 +346,6 @@ public class TestMain { if (signOutzao2 == 0){ try { signOutzao2 = autoWebTask.dutySignOutTask(1, yesterdaySignOutPerson, yesterdaySignOutPersonPassword); - if (signOutzao2 == 1){ - // TODO 更新昨日签退人员账号 - String value = GetBasicData.resolveGarbledCode("E:\\bns\\config\\今日值班账号.txt"); - AutoUtils.write("E:\\bns\\config\\昨日值班账号.txt", value.replace("今日","昨日")); - } }catch (Exception e){ log.error("签退",e); } @@ -344,24 +353,35 @@ public class TestMain { }catch (Exception e){ log.error("签退", e); } - } else if (DateTimeUtils.isEffectiveDate("09:05", "10:00")) { + } else if (DateTimeUtils.isEffectiveDate("08:50", "09:20")) { if(addExercisePlan == 0){ getTime(1200); } if(addExercisePlan == 0) { - String[] array = {"蒙城","利辛","涡阳"}; - Random random = new Random(); - int index = random.nextInt(array.length); - log.info("随机值为:" + index); - log.info("随机值为:" + array[index]); +// String[] array = {"蒙城","利辛","涡阳"}; +// Random random = new Random(); +// int index = random.nextInt(array.length); +// log.info("随机值为:" + index); +// log.info("随机值为:" + array[index]); Thread.sleep(2000); - addExercisePlan = autoWebTask.addExercisePlan("通信测试", array[index], index+1, emergencyPerson, + addExercisePlan = autoWebTask.addExercisePlan("通信测试", "", 1, emergencyPerson, emergencyPersonPassword); Thread.sleep(1000 * 700); - addExercisePlan = autoWebTask.addExercisePlan("日常操练", array[index], index+1, emergencyPerson, + addExercisePlan = autoWebTask.addExercisePlan("日常操练", "", 1, emergencyPerson, + emergencyPersonPassword); + Thread.sleep(1000 * 700); + addExercisePlan = autoWebTask.addExercisePlan("日常操练", "", 2, emergencyPerson, + emergencyPersonPassword); + Thread.sleep(1000 * 700); + addExercisePlan = autoWebTask.addExercisePlan("日常操练", "", 3, emergencyPerson, emergencyPersonPassword); Thread.sleep(2000); } + }else if (DateTimeUtils.isEffectiveDate("10:30", "10:35")) { + autoWebTask.changeTodayPersonaTask(1,emergencyPerson,emergencyPersonPassword); + // TODO 更新昨日签退人员账号 + String value = GetBasicData.resolveGarbledCode("E:\\bns\\config\\今日值班账号.txt"); + AutoUtils.write("E:\\bns\\config\\昨日值班账号.txt", value.replace("今日","昨日")); }else if (DateTimeUtils.isEffectiveDate("12:30", "14:30")) { //进行日志信息系统采集及获取工作 try { @@ -376,10 +396,10 @@ public class TestMain { }catch (Exception e) { log.error("信息采集工作", e); } - }else if (DateTimeUtils.isEffectiveDate("17:00", "17:40")) { + }else if (DateTimeUtils.isEffectiveDate("16:50", "17:20")) { //自动完成当值值班日报(晚报)填写上报 if (dailywan == 0) { - getTime(1500); + getTime(1200); try { dailywan = autoWebTask.dutyAddDailyLogsTask(2,emergencyPerson,emergencyPersonPassword); }catch (Exception e){ diff --git a/src/main/java/com/bonus/autoweb/base/AutoMain.java b/src/main/java/com/bonus/autoweb/base/AutoMain.java index d4749b0..f9422b9 100644 --- a/src/main/java/com/bonus/autoweb/base/AutoMain.java +++ b/src/main/java/com/bonus/autoweb/base/AutoMain.java @@ -39,7 +39,7 @@ public class AutoMain { //添加浏览器地址 // option.setBinary("C:\\Program Files\\Mozilla Firefox\\firefox.exe");//个人本地 // option.setBinary("C:\\Program Files\\Google\\Chrome\\Application\\chrome.exe");//个人本地 - option.setBinary("C:\\Program Files\\Google\\Chrome\\Application\\chrome.exe"); + option.setBinary("C:\\Program Files (x86)\\Google\\Chrome\\Application\\chrome.exe"); // option.setBinary("C:\\Users\\Administrator\\AppData\\Local\\Google\\Chrome\\Application\\chrome.exe");//宿州 // option.addArguments("start-fullscreen"); option.addArguments("--start-maximized"); @@ -86,7 +86,7 @@ public class AutoMain { public void openWeb() throws InterruptedException { //第一步打开指定网站 webDriver.get(DataConfig.URL); - log.info("打开宿州应急指挥中心网站------------"); + log.info("打开蒙城应急指挥中心网站------------"); Thread.sleep(2000); } @@ -166,7 +166,7 @@ public class AutoMain { //执行鼠标悬停动作-常态值班 - String ctzbXpath = "//*[@id=\"" + attributeId + "\"]/div/div[1]/div[2]/div[3]"; + String ctzbXpath = "//*[@id=\"" + attributeId + "\"]/div/div[1]/div[2]/div[4]"; WebElement wectzb = webDriver.findElement(By.xpath(ctzbXpath)); action.moveToElement(wectzb).build().perform(); Thread.sleep(300); @@ -293,17 +293,18 @@ public class AutoMain { //执行鼠标悬停动作-检查操练管理 String ctzbXpath = "//*[@id=\"" + attributeId + "\"]/div/div[1]/div[2]/div[5]"; - WebElement wectzb = webDriver.findElement(By.xpath(ctzbXpath)); - action.moveToElement(wectzb).build().perform(); - Thread.sleep(300); + webDriver.findElement(By.xpath(ctzbXpath)).click(); +// WebElement wectzb = +// action.moveToElement(wectzb).build().perform(); + Thread.sleep(1500); //打开日常操练页面 //*[@id=\"" + attributeId + "\"]/div/div[2]/div[2]/div[1]/div[2] - String zbglXpath = "//*[@id=\"" + attributeId + "\"]/div/div[2]/div[2]/div/div[1]"; - webDriver.findElement(By.xpath(zbglXpath)).click(); - log.info("打开日常操练页面------------"); - /* TODO 800 --> 1500 */ - Thread.sleep(1500); +// String zbglXpath = "//*[@id=\"" + attributeId + "\"]/div/div[2]/div[2]/div/div[1]"; +// webDriver.findElement(By.xpath(zbglXpath)).click(); +// log.info("打开日常操练页面------------"); +// /* TODO 800 --> 1500 */ +// Thread.sleep(1500); //定位日常操练iframe的标签 WebElement dutyIframe = webDriver.findElement(By.id("rccl")); @@ -311,10 +312,10 @@ public class AutoMain { log.info("定位到日常操练iframe-----------"); Thread.sleep(8000); //定位日常操练iframe的标签 - WebElement insideIframe = webDriver.findElement(By.xpath("/html/body/div/section/div[1]/div[2]/div/iframe")); - webDriver.switchTo().frame(insideIframe); - log.info("定位到日常操练内部iframe-----------"); - Thread.sleep(3000); +// WebElement insideIframe = webDriver.findElement(By.xpath("/html/body/div/section/div[1]/div[2]/div/iframe")); +// webDriver.switchTo().frame(insideIframe); +// log.info("定位到日常操练内部iframe-----------"); +// Thread.sleep(3000); } /** @@ -351,17 +352,18 @@ public class AutoMain { //执行鼠标悬停动作-检查操练管理 String ctzbXpath = "//*[@id=\"" + attributeId + "\"]/div/div[1]/div[2]/div[5]"; - WebElement wectzb = webDriver.findElement(By.xpath(ctzbXpath)); - action.moveToElement(wectzb).build().perform(); - Thread.sleep(300); + webDriver.findElement(By.xpath(ctzbXpath)).click(); +// WebElement wectzb = +// action.moveToElement(wectzb).build().perform(); + Thread.sleep(1500); //打开检查计划页面 //*[@id=\"" + attributeId + "\"]/div/div[2]/div[2]/div[1]/div[2] - String zbglXpath = "//*[@id=\"" + attributeId + "\"]/div/div[2]/div[2]/div/div[1]"; - webDriver.findElement(By.xpath(zbglXpath)).click(); - log.info("打开日常操练页面------------"); - /* TODO 800 --> 1500 */ - Thread.sleep(1500); +// String zbglXpath = "//*[@id=\"" + attributeId + "\"]/div/div[2]/div[2]/div/div[1]"; +// webDriver.findElement(By.xpath(zbglXpath)).click(); +// log.info("打开日常操练页面------------"); +// /* TODO 800 --> 1500 */ +// Thread.sleep(1500); //定位检查计划iframe的标签 WebElement dutyIframe = webDriver.findElement(By.id("rccl")); diff --git a/src/main/java/com/bonus/autoweb/base/DutyDailyOp.java b/src/main/java/com/bonus/autoweb/base/DutyDailyOp.java index eaf96a7..528fc8e 100644 --- a/src/main/java/com/bonus/autoweb/base/DutyDailyOp.java +++ b/src/main/java/com/bonus/autoweb/base/DutyDailyOp.java @@ -253,10 +253,18 @@ public class DutyDailyOp { // webDriver.findElement(By.xpath(operaxpath)).click(); // log.info("选择操作内容----------"); // Thread.sleep(300); - + String exerciseContent = "物资种类齐全,储存充足,维护保养到位,协议库存管理规范,物资展示效果良好,未发现其他问题.队伍精神面貌良好,着装,装备齐备,集结迅速,未发现问题.车辆维护保养到位," + + "运行良好,现场展示效果良好,未发现问题"; + String videoContent = "能迅速将现场视频传输至应急指挥中心,相应设备视频正常在线,现场视频清晰,无卡顿.应急指挥中心能够熟练将i国网,智慧应急app视频连线画面进行回传,现场基本资料齐全," + + "现场防汛," + + "消防," + + "保卫工作按要求开闸"; try { + WebElement codeEle = webDriver.findElement(By.xpath("/html/body/div/div/section/div/div[4]/div[1]/div[1" + + "]/div" + + "[2]/div/div/div[3]/table/tbody/tr[1]/td[3]/div")); WebElement personNumEle = webDriver.findElement(By.xpath("/html/body/div/div/section/div/div[4]/div[1]/div[1]/div[2]/div/div/div[3]/table/tbody/tr[1]/td[7]/div/div/input")); - personNumEle.sendKeys("无问题"); + personNumEle.sendKeys("通信测试".equals(codeEle.getText()) ? videoContent:exerciseContent); log.info("填写通信测试问题----------"); Thread.sleep(300); }catch (Exception e) { @@ -264,8 +272,11 @@ public class DutyDailyOp { } Thread.sleep(500); try { + WebElement codeEle1 = webDriver.findElement(By.xpath("/html/body/div/div/section/div/div[4]/div[1]/div[1" + + "]/div" + + "[2]/div/div/div[3]/table/tbody/tr[2]/td[3]/div")); WebElement carNumEle = webDriver.findElement(By.xpath("//html/body/div/div/section/div/div[4]/div[1]/div[1]/div[2]/div/div/div[3]/table/tbody/tr[2]/td[7]/div/div/input")); - carNumEle.sendKeys("无问题"); + carNumEle.sendKeys("通信测试".equals(codeEle1.getText()) ? videoContent:exerciseContent); log.info("填写四要素操练问题----------"); Thread.sleep(300); }catch (Exception e) { @@ -273,8 +284,11 @@ public class DutyDailyOp { } Thread.sleep(500); try { + WebElement codeEle2 = webDriver.findElement(By.xpath("/html/body/div/div/section/div/div[4]/div[1]/div[1" + + "]/div" + + "[2]/div/div/div[3]/table/tbody/tr[3]/td[3]/div")); WebElement fdcNumEle = webDriver.findElement(By.xpath("//html/body/div/div/section/div/div[4]/div[1]/div[1]/div[2]/div/div/div[3]/table/tbody/tr[3]/td[7]/div/div/input")); - fdcNumEle.sendKeys("无问题"); + fdcNumEle.sendKeys("通信测试".equals(codeEle2.getText()) ? videoContent:exerciseContent); log.info("填写重大战线视频连线检查问题----------"); Thread.sleep(1000); }catch (Exception e) { @@ -776,52 +790,52 @@ public class DutyDailyOp { Thread.sleep(300); - //填写人员数量 - String personNum = obj.getInput_amount_person(); - WebElement ryslEle = webDriver.findElement(By.xpath("//*[@id=\"app\"]/div/section/div/div[4]/div[1]/div[6]/div/div[2]/div/div/div[3]/table/tbody/tr/td[10]/div/div/div/input")); - ryslEle.clear(); - Thread.sleep(300); - ryslEle.sendKeys(personNum); - log.info("填写人员数量----------"); - Thread.sleep(300); - - - //填写车辆数量 - String carNum = obj.getInput_amount_vehicle(); - WebElement clslEle = webDriver.findElement(By.xpath("//*[@id=\"app\"]/div/section/div/div[4]/div[1]/div[6]/div/div[2]/div/div/div[3]/table/tbody/tr/td[11]/div/div/div/input")); - clslEle.clear(); - Thread.sleep(300); - clslEle.sendKeys(carNum); - log.info("填写车辆数量----------"); - Thread.sleep(300); - - - //填写发电车数量 - String fdcNum = obj.getInput_amount_power_vehicle(); - WebElement fdcNumEle = webDriver.findElement(By.xpath("//*[@id=\"app\"]/div/section/div/div[4]/div[1]/div[6]/div/div[2]/div/div/div[3]/table/tbody/tr/td[12]/div/div/div/input")); - fdcNumEle.clear(); - Thread.sleep(300); - fdcNumEle.sendKeys(fdcNum); - log.info("填写发电车数量----------"); - Thread.sleep(300); - - - //填写发电机数量 - String fdjNum = obj.getInput_amount_dynamo(); - WebElement fdjNumEle = webDriver.findElement(By.xpath("//*[@id=\"app\"]/div/section/div/div[4]/div[1]/div[6]/div/div[2]/div/div/div[3]/table/tbody/tr/td[13]/div/div/div/input")); - fdjNumEle.clear(); - Thread.sleep(300); - fdjNumEle.sendKeys(fdjNum); - log.info("填写发电机数量----------"); - Thread.sleep(300); - - - String bz = obj.getRemark(); - WebElement bzEle = webDriver.findElement(By.xpath("//*[@id=\"app\"]/div/section/div/div[4]/div[1]/div[6]/div/div[2]/div/div/div[3]/table/tbody/tr/td[14]/div/div/input")); - bzEle.clear(); - bzEle.sendKeys(bz); - log.info("填写备注----------"); - Thread.sleep(300); +// //填写人员数量 +// String personNum = obj.getInput_amount_person(); +// WebElement ryslEle = webDriver.findElement(By.xpath("//*[@id=\"app\"]/div/section/div/div[4]/div[1]/div[6]/div/div[2]/div/div/div[3]/table/tbody/tr/td[10]/div/div/div/input")); +// ryslEle.clear(); +// Thread.sleep(300); +// ryslEle.sendKeys(personNum); +// log.info("填写人员数量----------"); +// Thread.sleep(300); +// +// +// //填写车辆数量 +// String carNum = obj.getInput_amount_vehicle(); +// WebElement clslEle = webDriver.findElement(By.xpath("//*[@id=\"app\"]/div/section/div/div[4]/div[1]/div[6]/div/div[2]/div/div/div[3]/table/tbody/tr/td[11]/div/div/div/input")); +// clslEle.clear(); +// Thread.sleep(300); +// clslEle.sendKeys(carNum); +// log.info("填写车辆数量----------"); +// Thread.sleep(300); +// +// +// //填写发电车数量 +// String fdcNum = obj.getInput_amount_power_vehicle(); +// WebElement fdcNumEle = webDriver.findElement(By.xpath("//*[@id=\"app\"]/div/section/div/div[4]/div[1]/div[6]/div/div[2]/div/div/div[3]/table/tbody/tr/td[12]/div/div/div/input")); +// fdcNumEle.clear(); +// Thread.sleep(300); +// fdcNumEle.sendKeys(fdcNum); +// log.info("填写发电车数量----------"); +// Thread.sleep(300); +// +// +// //填写发电机数量 +// String fdjNum = obj.getInput_amount_dynamo(); +// WebElement fdjNumEle = webDriver.findElement(By.xpath("//*[@id=\"app\"]/div/section/div/div[4]/div[1]/div[6]/div/div[2]/div/div/div[3]/table/tbody/tr/td[13]/div/div/div/input")); +// fdjNumEle.clear(); +// Thread.sleep(300); +// fdjNumEle.sendKeys(fdjNum); +// log.info("填写发电机数量----------"); +// Thread.sleep(300); +// +// +// String bz = obj.getRemark(); +// WebElement bzEle = webDriver.findElement(By.xpath("//*[@id=\"app\"]/div/section/div/div[4]/div[1]/div[6]/div/div[2]/div/div/div[3]/table/tbody/tr/td[14]/div/div/input")); +// bzEle.clear(); +// bzEle.sendKeys(bz); +// log.info("填写备注----------"); +// Thread.sleep(300); } dailySchedule7(bean.getSevenBean(), bean); // submitData(); diff --git a/src/main/java/com/bonus/autoweb/base/DutyLogIOp.java b/src/main/java/com/bonus/autoweb/base/DutyLogIOp.java index 0105e81..5eb525f 100644 --- a/src/main/java/com/bonus/autoweb/base/DutyLogIOp.java +++ b/src/main/java/com/bonus/autoweb/base/DutyLogIOp.java @@ -3,6 +3,7 @@ package com.bonus.autoweb.base; import com.bonus.autoweb.DateTimeUtils; import com.bonus.autoweb.TestMain; import com.bonus.autoweb.UI.entity.LogBean; +import com.bonus.autoweb.UI.frame.StringHelper; import com.thoughtworks.xstream.XStream; import com.thoughtworks.xstream.io.json.JettisonMappedXmlDriver; import org.openqa.selenium.By; @@ -182,26 +183,38 @@ public class DutyLogIOp { LogBean bean = (LogBean) xstream.fromXML(xml); -// //输入天气 -// String tq = bean.getWeather(); -//// /html/body/div[3]/div/div[2]/div/form/div[3]/div/div/div[3]/div/div/div[1]/input -// webDriver.findElement(By.xpath("/html/body/div[3]/div/div[2]/div/form/div[3]/div/div/div[5]/div/div/div/input")).sendKeys(tq); -// log.info("输入天气----------"); -// Thread.sleep(500); + //输入天气 + String tq = bean.getWeather(); +// /html/body/div[3]/div/div[2]/div/form/div[3]/div/div/div[3]/div/div/div[1]/input + WebElement weatherElement = webDriver.findElement(By.xpath("/html/body/div[3]/div/div[2]/div/form/div[3]/div/div/div[5]/div/div/div/input")); + if (StringHelper.isEmptyAndNull(weatherElement.getText())){ + weatherElement.clear(); + weatherElement.sendKeys(tq); + log.info("输入天气----------"); + } + Thread.sleep(500); -// //输入最低气温 -// String zdqw = bean.getMin_temperature(); -//// /html/body/div[3]/div/div[2]/div/form/div[3]/div/div/div[4]/div/div/div[1]/input -// webDriver.findElement(By.xpath("/html/body/div[3]/div/div[2]/div/form/div[3]/div/div/div[7]/div/div/div/input")).sendKeys(zdqw); -// log.info("输入最高气温----------"); -// Thread.sleep(500); + //输入最低气温 + String zdqw = bean.getMin_temperature(); +// /html/body/div[3]/div/div[2]/div/form/div[3]/div/div/div[4]/div/div/div[1]/input + WebElement minTemperatureElement = webDriver.findElement(By.xpath("/html/body/div[3]/div/div[2]/div/form/div[3]/div/div/div[7]/div/div/div/input")); + if (StringHelper.isEmptyAndNull(minTemperatureElement.getText())){ + minTemperatureElement.clear(); + minTemperatureElement.sendKeys(zdqw); + log.info("输入最低气温----------"); + } + Thread.sleep(500); -// //输入最高气温 -// String zgqw = bean.getMax_temperature(); -//// /html/body/div[3]/div/div[2]/div/form/div[3]/div/div/div[4]/div/div/div[1]/input -// webDriver.findElement(By.xpath("/html/body/div[3]/div/div[2]/div/form/div[3]/div/div/div[9]/div/div/div/input")).sendKeys(zgqw); -// log.info("输入最高气温----------"); -// Thread.sleep(500); + //输入最高气温 + String zgqw = bean.getMax_temperature(); +// /html/body/div[3]/div/div[2]/div/form/div[3]/div/div/div[4]/div/div/div[1]/input + WebElement maxTemperatureElement = webDriver.findElement(By.xpath("/html/body/div[3]/div/div[2]/div/form/div[3]/div/div/div[9]/div/div/div/input")); + if (StringHelper.isEmptyAndNull(maxTemperatureElement.getText())){ + maxTemperatureElement.clear(); + maxTemperatureElement.sendKeys(zgqw); + log.info("输入最高气温----------"); + } + Thread.sleep(500); //事件监测 标题 String sjjc_title = bean.getEvent_detection_title(); diff --git a/src/main/java/com/bonus/autoweb/task/AutoWebTask.java b/src/main/java/com/bonus/autoweb/task/AutoWebTask.java index 789ca26..0ea514f 100644 --- a/src/main/java/com/bonus/autoweb/task/AutoWebTask.java +++ b/src/main/java/com/bonus/autoweb/task/AutoWebTask.java @@ -155,6 +155,7 @@ public class AutoWebTask { autoMain.startAuto(username, password); //操作日志 webDriver = autoMain.getWebDriver(); + Thread.sleep(3000); //获取账号姓名 和 账号名 WebElement personNameEle = webDriver.findElement(By.xpath("//*[@id='pane-1']/div/div[3]/div/div/div[3" + "]/table/tbody/tr[2]/td[2]/div/div/p[1]")); @@ -164,6 +165,7 @@ public class AutoWebTask { "]/table/tbody/tr[2]/td[2]/div/div/p[2]")); String account = accountEle.getText(); log.info("今日值班人员账号:" + account); + Thread.sleep(3000); excelFile = new FileInputStream("E:\\bns\\config\\zhibanaccount.xlsx"); workbook = new XSSFWorkbook(excelFile); Sheet datatypeSheet = workbook.getSheetAt(0);