From 85716e216b30d87f5e646f16f5601cefa39d0db3 Mon Sep 17 00:00:00 2001 From: jjLv <1981429112@qq.com> Date: Mon, 23 Dec 2024 17:23:17 +0800 Subject: [PATCH] =?UTF-8?q?refactor(path):=20=E6=9B=B4=E6=96=B0=E6=96=87?= =?UTF-8?q?=E4=BB=B6=E8=B7=AF=E5=BE=84=E5=92=8C=E6=B5=8F=E8=A7=88=E5=99=A8?= =?UTF-8?q?=E9=85=8D=E7=BD=AE?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit - 更新 DataConfig 中的 URL 和驱动路径 - 修改 DutyLogIOp 中的元素定位方式 - 调整 GetBasicData 中的文件读取路径 - 修改日志输出路径 --- .../java/com/bonus/autoweb/GetBasicData.java | 71 ++++++------ src/main/java/com/bonus/autoweb/TestMain.java | 5 +- .../java/com/bonus/autoweb/base/AutoMain.java | 14 +-- .../com/bonus/autoweb/base/DataConfig.java | 6 +- .../bonus/autoweb/base/DutyDailyCheck.java | 4 +- .../com/bonus/autoweb/base/DutyDailyOp.java | 94 ++++++++-------- .../com/bonus/autoweb/base/DutyLogIOp.java | 103 +++++++++++------- src/main/resources/log4j.properties | 4 +- 8 files changed, 161 insertions(+), 140 deletions(-) diff --git a/src/main/java/com/bonus/autoweb/GetBasicData.java b/src/main/java/com/bonus/autoweb/GetBasicData.java index 3e3dc1a..4f9b348 100644 --- a/src/main/java/com/bonus/autoweb/GetBasicData.java +++ b/src/main/java/com/bonus/autoweb/GetBasicData.java @@ -247,7 +247,8 @@ public class GetBasicData { public void getYuJingBasicData(int classes) throws ParseException, InterruptedException { Thread.sleep(5000); String code = ""; - String code_child = "共安排抢险队伍12支,合计167人(主业159人、外包8人)、车辆12台、发电机4台值守待命,准备照明灯具40套、配变10台、电缆5千米、电杆50根、绝缘子100只。"; + + String code_child = "灵璧公司安排抢修以伍12支(主网10支,配网2支)、车辆12台、发电机1台、照明灯40套、配变10台、箱变4台、电缆1千米、电杆50根、金具50套、绝缘子100串。"; String code_chlid2 = "针对此次预警,今日宿州灵璧供电公司开展预警响应,对重要保电线路、变电站进行特巡,安排抢修队伍、绑定应急车辆、装备,抢修队长,通过i" + "国网反馈巡视照片、视频,在新一代系统里均形成巡视记录、车辆队伍轨迹,未发现问题。"; //判断是否有发布数据 @@ -284,8 +285,8 @@ public class GetBasicData { DailyBean dailyBean = readDailyBean("morning_daily"); DailyBean dailyBean2 = readDailyBean("evening_daily"); LogBean logBean = readDutyBean(); - String dailyContent = resolveGarbledCode("E:\\bns\\config\\日报基本信息.txt"); - String logContent = resolveGarbledCode("E:\\bns\\config\\日志基本信息.txt"); + String dailyContent = resolveGarbledCode("D:\\bns\\config\\日报基本信息.txt"); + String logContent = resolveGarbledCode("D:\\bns\\config\\日志基本信息.txt"); String[] dailyContentArrayArray = dailyContent.split("--头部不可修改--"); String[] logContentArrayArray = logContent.split("--头部不可修改--"); log.info("dailyContent:" + dailyContent); @@ -313,7 +314,7 @@ public class GetBasicData { logBean.setGeneral_chronicles_content(logBean.getGeneral_chronicles_content()); insertData(null, logBean, "log"); log.info("天气预警日志更新完成"); - dailyBean.setWarning_company(data+code + dailyContentArrayArray[20]+code_chlid2); + dailyBean.setWarning_company(data+code + code_child + dailyContentArrayArray[20]+code_chlid2); //一、总体情况 dailyBean.setOverall(data + dailyContentArrayArray[2].trim() + (classes == 1 ? data3+"08:30," : data2+"17:30" + @@ -325,7 +326,7 @@ public class GetBasicData { ",") + dailyContentArrayArray[3].trim() + code + "对系统检测图层中气象实况风速、温度、降雨进行查看、对专题灾害图层地震、台风防汛进行查看均正常,未对宿州灵璧辖区造成影响。通过首页公共气象图层检查宿州灵璧内公共预警正常;降雨预报、预警正常;雷达预报正常。"); dailyBean2.setPersonnel_daily_work(dailyBean2.getPersonnel_daily_work()); - dailyBean2.setWarning_company(data+code+ dailyContentArrayArray[20]+code_chlid2); + dailyBean2.setWarning_company(data+code+ code_child + dailyContentArrayArray[20]+code_chlid2); insertData(dailyBean, null, "morning_daily"); insertData(dailyBean2, null, "evening_daily"); log.info("日志内容:" + readDutyBean()); @@ -337,10 +338,10 @@ public class GetBasicData { DailyBean dailyBean = readDailyBean("morning_daily"); DailyBean dailyBean2 = readDailyBean("evening_daily"); LogBean logBean = readDutyBean(); - String dailyContent = resolveGarbledCode("E:\\bns\\config\\日报基本信息.txt"); - String checkContent = resolveGarbledCode("E:\\bns\\config\\资源核查情况.txt"); - String logContent = resolveGarbledCode("E:\\bns\\config\\日志基本信息.txt"); - String videoContent = resolveGarbledCode("E:\\bns\\config\\变电站名称.txt"); + String dailyContent = resolveGarbledCode("D:\\bns\\config\\日报基本信息.txt"); + String checkContent = resolveGarbledCode("D:\\bns\\config\\资源核查情况.txt"); + String logContent = resolveGarbledCode("D:\\bns\\config\\日志基本信息.txt"); + String videoContent = resolveGarbledCode("D:\\bns\\config\\变电站名称.txt"); String[] dailyContentArrayArray = dailyContent.split("--头部不可修改--"); String[] logContentArrayArray = logContent.split("--头部不可修改--"); String[] checkContentArrayArray = checkContent.split("资源核查情况:"); @@ -573,10 +574,10 @@ public class GetBasicData { DailyBean dailyBean = readDailyBean("morning_daily"); DailyBean dailyBean2 = readDailyBean("evening_daily"); LogBean logBean = readDutyBean(); - String dailyContent = resolveGarbledCode("E:\\bns\\config\\日报基本信息.txt"); - String checkContent = resolveGarbledCode("E:\\bns\\config\\资源核查情况.txt"); - String logContent = resolveGarbledCode("E:\\bns\\config\\日志基本信息.txt"); - String videoContent = resolveGarbledCode("E:\\bns\\config\\变电站名称.txt"); + String dailyContent = resolveGarbledCode("D:\\bns\\config\\日报基本信息.txt"); + String checkContent = resolveGarbledCode("D:\\bns\\config\\资源核查情况.txt"); + String logContent = resolveGarbledCode("D:\\bns\\config\\日志基本信息.txt"); + String videoContent = resolveGarbledCode("D:\\bns\\config\\变电站名称.txt"); String[] dailyContentArrayArray = dailyContent.split("--头部不可修改--"); String[] logContentArrayArray = logContent.split("--头部不可修改--"); String[] checkContentArrayArray = checkContent.split("资源核查情况:"); @@ -653,7 +654,7 @@ public class GetBasicData { private void executePlan(String type, String company, String projectName) throws InterruptedException { Thread.sleep(2000); - String checkContent = resolveGarbledCode("E:\\bns\\config\\检查计划评价.txt"); + String checkContent = resolveGarbledCode("D:\\bns\\config\\检查计划评价.txt"); String[] checkContentArrayArray = checkContent.split("检查评价:"); //勾选计划 webDriver.findElement(By.xpath("/html/body/div[1]/section/div[1]/div[2]/div[2]/section/main/section/main/div/div[3]/table/tbody/tr[1]")).click(); @@ -781,29 +782,29 @@ public class GetBasicData { webDriver.findElement(By.xpath("/html/body/div[6]/div[1]/div/div/div[1]/div[1]/span[2]")).click(); log.info("选择被检查单位----------"); Thread.sleep(500); - //选择被检查对象 - webDriver.findElement(By.xpath("/html/body/div[3]/div/div[2]/section/header/form/div/div[5]/div/div[2]")).click(); - Thread.sleep(3000); - if("通信测试".equals(type)){ - webDriver.findElement(By.xpath("/html/body/div[7]/div/div[2]/section/main/div[1]/div[3]/table/tbody/tr[1]/td[1]/div/label")).click(); - Thread.sleep(500); - webDriver.findElement(By.xpath("/html/body/div[7]/div/div[2]/section/main/div[1]/div[3]/table/tbody/tr[2" + - "]/td[1]/div/label")).click(); - Thread.sleep(1000); - webDriver.findElement(By.xpath("/html/body/div[7]/div/div[2]/section/footer/button[2]")).click(); - Thread.sleep(2000); - }else { - for (int i = 1; i < 5; i++) { - webDriver.findElement(By.xpath("/html/body/div[7]/div/div[2]/section/main/div[1]/div[3]/table" + - "/tbody/tr["+i+"]/td[1]/div/label")).click(); - Thread.sleep(1000); - } - webDriver.findElement(By.xpath("/html/body/div[7]/div/div[2]/section/footer[2]/button[2]")).click(); - Thread.sleep(2000); - } +// //选择被检查对象 +// webDriver.findElement(By.xpath("/html/body/div[3]/div/div[2]/section/header/form/div/div[5]/div/div[2]")).click(); +// Thread.sleep(3000); +// if("通信测试".equals(type)){ +// webDriver.findElement(By.xpath("/html/body/div[7]/div/div[2]/section/main/div[1]/div[3]/table/tbody/tr[1]/td[1]/div/label")).click(); +// Thread.sleep(500); +// webDriver.findElement(By.xpath("/html/body/div[7]/div/div[2]/section/main/div[1]/div[3]/table/tbody/tr[2" + +// "]/td[1]/div/label")).click(); +// Thread.sleep(1000); +// webDriver.findElement(By.xpath("/html/body/div[7]/div/div[2]/section/footer/button[2]")).click(); +// Thread.sleep(2000); +// }else { +// for (int i = 1; i < 5; i++) { +// webDriver.findElement(By.xpath("/html/body/div[7]/div/div[2]/section/main/div[1]/div[3]/table" + +// "/tbody/tr["+i+"]/td[1]/div/label")).click(); +// Thread.sleep(1000); +// } +// webDriver.findElement(By.xpath("/html/body/div[7]/div/div[2]/section/footer[2]/button[2]")).click(); +// Thread.sleep(2000); +// } Thread.sleep(3000); //提交 - webDriver.findElement(By.xpath("/html/body/div[2]/div/div[2]/section/div/button[3]")).click(); + webDriver.findElement(By.xpath("/html/body/div[4]/div/div[2]/section/div/button[3]")).click(); Thread.sleep(3000); } diff --git a/src/main/java/com/bonus/autoweb/TestMain.java b/src/main/java/com/bonus/autoweb/TestMain.java index b3cb5f4..670d292 100644 --- a/src/main/java/com/bonus/autoweb/TestMain.java +++ b/src/main/java/com/bonus/autoweb/TestMain.java @@ -310,7 +310,7 @@ public class TestMain { DataConfig.PASS1); Thread.sleep(2000); } - } else if (DateTimeUtils.isEffectiveDate("12:30", "16:20")) { + }else if (DateTimeUtils.isEffectiveDate("12:30", "16:20")) { //进行日志信息系统采集及获取工作 try { if (logGatherCount1 == 0){ @@ -336,6 +336,7 @@ public class TestMain { } } }else if (DateTimeUtils.isEffectiveDate("16:30", "16:45")) { +// }else if (DateTimeUtils.isEffectiveDate("10:00", "16:45")) { //完成值班日志填写提交(白班日志,此次值班日志为总结前一天晚上的情况) if (logwan == 0) { getTime(600); @@ -503,7 +504,7 @@ public class TestMain { // 设置文件输出流格式 Dispatch.putRef(spFileStream, "Format", spAudioFormat); // 调用输出 文件流打开方法,创建一个.wav文件 - Dispatch.call(spFileStream, "Open", new Variant("E:\\bns\\audio.wav"), new Variant(3), new Variant(true)); + Dispatch.call(spFileStream, "Open", new Variant("D:\\bns\\audio.wav"), new Variant(3), new Variant(true)); // 设置声音对象的音频输出流为输出文件对象 Dispatch.putRef(spVoice, "AudioOutputStream", spFileStream); // 设置音量 0到100 diff --git a/src/main/java/com/bonus/autoweb/base/AutoMain.java b/src/main/java/com/bonus/autoweb/base/AutoMain.java index 77ea779..09d3b77 100644 --- a/src/main/java/com/bonus/autoweb/base/AutoMain.java +++ b/src/main/java/com/bonus/autoweb/base/AutoMain.java @@ -39,7 +39,8 @@ public class AutoMain { option.setBinary("C:\\Program Files\\Google\\Chrome\\Application\\chrome.exe"); option.addArguments("--start-maximized"); - option.addArguments("--force-device-scale-factor=0.75"); +// option.addArguments("--force-device-scale-factor=0.75"); + option.addArguments("--force-device-scale-factor=0.6"); option.addArguments("disable-infobars"); // if(type != 7) { // //隐藏浏览器 @@ -211,17 +212,6 @@ public class AutoMain { String attributeId = wegl.getAttribute("aria-describedby"); log.info("管理标签的ID值为:" + attributeId); Thread.sleep(300); - - -// //执行鼠标悬停动作-常态值班 -// String ctzbXpath = "//*[@id=\"" + attributeId + "\"]/div/div[1]/div[2]/div[3]"; -// WebElement wectzb = webDriver.findElement(By.xpath(ctzbXpath)); -// action.moveToElement(wectzb).build().perform(); -// Thread.sleep(300); - - - //打开预警响应管理页面 - //*[@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(); log.info("打开预警页面------------"); diff --git a/src/main/java/com/bonus/autoweb/base/DataConfig.java b/src/main/java/com/bonus/autoweb/base/DataConfig.java index fe7e61b..a8f93e5 100644 --- a/src/main/java/com/bonus/autoweb/base/DataConfig.java +++ b/src/main/java/com/bonus/autoweb/base/DataConfig.java @@ -6,7 +6,7 @@ public class DataConfig { /** * url 网站地址 */ - protected static final String URL = "http://20.50.16.10/ecs/#/yjtsgz"; + protected static final String URL = "http://xydyjzh.ah.sgcc.com.cn"; /** * 驱动名称 */ @@ -35,11 +35,11 @@ public class DataConfig { /** * 浏览器驱动地址 */ - protected static final String drivePath = "E:\\bns\\chromedriver_win32\\chromedriver.exe"; + protected static final String drivePath = "D:\\bns\\chromedriver_win32\\chromedriver.exe"; /** * 文件地址 */ - public static final String filePath = "E:\\bns\\config"; + public static final String filePath = "D:\\bns\\config"; public static String weatherUrl = "http://10.138.4.27:9021/EPCIM/control/ypdgt/qxyj/getQXYJ?city=灵璧&rectime="+ DateTimeUtils.getCurrentDay(); diff --git a/src/main/java/com/bonus/autoweb/base/DutyDailyCheck.java b/src/main/java/com/bonus/autoweb/base/DutyDailyCheck.java index 1caa89e..7089364 100644 --- a/src/main/java/com/bonus/autoweb/base/DutyDailyCheck.java +++ b/src/main/java/com/bonus/autoweb/base/DutyDailyCheck.java @@ -37,9 +37,9 @@ public class DutyDailyCheck { String checkXpath; //早报 if(type ==1){ - checkXpath="//*[@id=\"pane-4\"]/div/div[3]/div/div/div[3]/table/tbody/tr[1]/td[5]/div/p[2]"; + checkXpath="//*[@id=\"pane-4\"]/div/div[3]/div/div/div[3]/table/tbody/tr[1]/td[5]/div/div/p[2]"; }else{ - checkXpath="//*[@id=\"pane-4\"]/div/div[3]/div/div/div[3]/table/tbody/tr[2]/td[5]/div/p[2]"; + checkXpath="//*[@id=\"pane-4\"]/div/div[3]/div/div/div[3]/table/tbody/tr[2]/td[5]/div/div/p[2]"; } //点击审核按钮 diff --git a/src/main/java/com/bonus/autoweb/base/DutyDailyOp.java b/src/main/java/com/bonus/autoweb/base/DutyDailyOp.java index e612d56..dd7ffeb 100644 --- a/src/main/java/com/bonus/autoweb/base/DutyDailyOp.java +++ b/src/main/java/com/bonus/autoweb/base/DutyDailyOp.java @@ -49,9 +49,9 @@ public class DutyDailyOp { Thread.sleep(500); //早报编辑标签定位 - String zaoBxPath = "//*[@id=\"pane-4\"]/div/div[3]/div/div/div[3]/table/tbody/tr[1]/td[5]/div/p[1]"; + String zaoBxPath = "//*[@id=\"pane-4\"]/div/div[3]/div/div/div[3]/table/tbody/tr[1]/td[5]/div/div/p[1]"; //晚报编辑标签定位 - String wanBxpath = "//*[@id=\"pane-4\"]/div/div[3]/div/div/div[3]/table/tbody/tr[2]/td[5]/div/p[1]"; + String wanBxpath = "//*[@id=\"pane-4\"]/div/div[3]/div/div/div[3]/table/tbody/tr[2]/td[5]/div/div/p[1]"; if (type == 1) { webDriver.findElement(By.xpath(zaoBxPath)).click(); } else { @@ -379,21 +379,21 @@ public class DutyDailyOp { //操作附表3 无 // private void dailySchedule3(AnnexThreeBean obj, DailyBean bean) throws InterruptedException { -//// //填写合计-新增-确诊 -//// String totalAddDiagnosedNum = obj.getTotalAddDiagnosed(); -//// WebElement totalAddDiagnosedEle= webDriver.findElement(By.xpath("//*[@id=\"app\"]/div/section/div/div[4]/div[1]/div[2]/div[2]/div/div/div[3]/table/tbody/tr/td[3]/div/div/input")); -//// totalAddDiagnosedEle.clear(); -//// totalAddDiagnosedEle.sendKeys(totalAddDiagnosedNum); -//// log.info("填写合计-新增-确诊----------"); -//// Thread.sleep(300); -//// -//// //填写合计-现有-确诊 -//// String totalExistingDiagnosedNum = obj.getTotalExistingDiagnosed(); -//// WebElement totalExistingDiagnosedNumEle= webDriver.findElement(By.xpath("//*[@id=\"app\"]/div/section/div/div[4]/div[1]/div[2]/div[2]/div/div/div[3]/table/tbody/tr/td[4]/div/div/input")); -//// totalExistingDiagnosedNumEle.clear(); -//// totalExistingDiagnosedNumEle.sendKeys(totalExistingDiagnosedNum); -//// log.info("填写合计-现有-确诊----------"); -//// Thread.sleep(300); +// //填写合计-新增-确诊 +// String totalAddDiagnosedNum = obj.getTotalAddDiagnosed(); +// WebElement totalAddDiagnosedEle= webDriver.findElement(By.xpath("//*[@id=\"app\"]/div/section/div/div[4]/div[1]/div[2]/div[2]/div/div/div[3]/table/tbody/tr/td[3]/div/div/input")); +// totalAddDiagnosedEle.clear(); +// totalAddDiagnosedEle.sendKeys(totalAddDiagnosedNum); +// log.info("填写合计-新增-确诊----------"); +// Thread.sleep(300); +// +// //填写合计-现有-确诊 +// String totalExistingDiagnosedNum = obj.getTotalExistingDiagnosed(); +// WebElement totalExistingDiagnosedNumEle= webDriver.findElement(By.xpath("//*[@id=\"app\"]/div/section/div/div[4]/div[1]/div[2]/div[2]/div/div/div[3]/table/tbody/tr/td[4]/div/div/input")); +// totalExistingDiagnosedNumEle.clear(); +// totalExistingDiagnosedNumEle.sendKeys(totalExistingDiagnosedNum); +// log.info("填写合计-现有-确诊----------"); +// Thread.sleep(300); // // try { // //填写电网调度-新增-确诊 @@ -485,21 +485,21 @@ public class DutyDailyOp { // log.info("填写电网建设-新增-确诊不存在此元素----------"); // } // -//// //填写合计-新增-治愈 -//// String totalAddHealNum = obj.getTotalAddHeal(); -//// WebElement totalAddHealEle= webDriver.findElement(By.xpath("//*[@id=\"app\"]/div/section/div/div[4]/div[1]/div[2]/div[2]/div/div/div[3]/table/tbody/tr/td[3]/div/div/input")); -//// totalAddHealEle.clear(); -//// totalAddHealEle.sendKeys(totalAddHealNum); -//// log.info("填写合计-新增-治愈----------"); -//// Thread.sleep(300); -//// -//// //填写合计-现有-治愈 -//// String totalExistingHealNum = obj.getTotalExistingHeal(); -//// WebElement totalExistingHealNumEle= webDriver.findElement(By.xpath("//*[@id=\"app\"]/div/section/div/div[4]/div[1]/div[2]/div[2]/div/div/div[3]/table/tbody/tr/td[4]/div/div/input")); -//// totalExistingHealNumEle.clear(); -//// totalExistingHealNumEle.sendKeys(totalExistingHealNum); -//// log.info("填写合计-现有-治愈----------"); -//// Thread.sleep(300); +// //填写合计-新增-治愈 +// String totalAddHealNum = obj.getTotalAddHeal(); +// WebElement totalAddHealEle= webDriver.findElement(By.xpath("//*[@id=\"app\"]/div/section/div/div[4]/div[1]/div[2]/div[2]/div/div/div[3]/table/tbody/tr/td[3]/div/div/input")); +// totalAddHealEle.clear(); +// totalAddHealEle.sendKeys(totalAddHealNum); +// log.info("填写合计-新增-治愈----------"); +// Thread.sleep(300); +// +// //填写合计-现有-治愈 +// String totalExistingHealNum = obj.getTotalExistingHeal(); +// WebElement totalExistingHealNumEle= webDriver.findElement(By.xpath("//*[@id=\"app\"]/div/section/div/div[4]/div[1]/div[2]/div[2]/div/div/div[3]/table/tbody/tr/td[4]/div/div/input")); +// totalExistingHealNumEle.clear(); +// totalExistingHealNumEle.sendKeys(totalExistingHealNum); +// log.info("填写合计-现有-治愈----------"); +// Thread.sleep(300); // // try { // //填写电网调度-新增-治愈 @@ -575,21 +575,21 @@ public class DutyDailyOp { // constructionExistingHealEle.sendKeys(constructionExistingHealNum); // log.info("填写营销服务-现有-治愈----------"); // -//// //填写合计-新增-疑似 -//// String totalAddSuspectedNum = obj.getTotalAddSuspected(); -//// WebElement totalAddSuspectedEle= webDriver.findElement(By.xpath("//*[@id=\"app\"]/div/section/div/div[4]/div[1]/div[2]/div[2]/div/div/div[3]/table/tbody/tr/td[3]/div/div/input")); -//// totalAddSuspectedEle.clear(); -//// totalAddSuspectedEle.sendKeys(totalAddSuspectedNum); -//// log.info("填写合计-新增-疑似----------"); -//// Thread.sleep(300); -//// -//// //填写合计-现有-疑似 -//// String totalExistingSuspectedNum = obj.getTotalExistingSuspected(); -//// WebElement totalExistingSuspectedNumEle= webDriver.findElement(By.xpath("//*[@id=\"app\"]/div/section/div/div[4]/div[1]/div[2]/div[2]/div/div/div[3]/table/tbody/tr/td[4]/div/div/input")); -//// totalExistingSuspectedNumEle.clear(); -//// totalExistingSuspectedNumEle.sendKeys(totalExistingSuspectedNum); -//// log.info("填写合计-现有-疑似----------"); -//// Thread.sleep(300); +// //填写合计-新增-疑似 +// String totalAddSuspectedNum = obj.getTotalAddSuspected(); +// WebElement totalAddSuspectedEle= webDriver.findElement(By.xpath("//*[@id=\"app\"]/div/section/div/div[4]/div[1]/div[2]/div[2]/div/div/div[3]/table/tbody/tr/td[3]/div/div/input")); +// totalAddSuspectedEle.clear(); +// totalAddSuspectedEle.sendKeys(totalAddSuspectedNum); +// log.info("填写合计-新增-疑似----------"); +// Thread.sleep(300); +// +// //填写合计-现有-疑似 +// String totalExistingSuspectedNum = obj.getTotalExistingSuspected(); +// WebElement totalExistingSuspectedNumEle= webDriver.findElement(By.xpath("//*[@id=\"app\"]/div/section/div/div[4]/div[1]/div[2]/div[2]/div/div/div[3]/table/tbody/tr/td[4]/div/div/input")); +// totalExistingSuspectedNumEle.clear(); +// totalExistingSuspectedNumEle.sendKeys(totalExistingSuspectedNum); +// log.info("填写合计-现有-疑似----------"); +// Thread.sleep(300); // // //填写电网调度-新增-疑似 // String dispatchAddSuspectedNum = obj.getDispatchAddSuspected(); diff --git a/src/main/java/com/bonus/autoweb/base/DutyLogIOp.java b/src/main/java/com/bonus/autoweb/base/DutyLogIOp.java index f5ef5a5..02b097c 100644 --- a/src/main/java/com/bonus/autoweb/base/DutyLogIOp.java +++ b/src/main/java/com/bonus/autoweb/base/DutyLogIOp.java @@ -6,8 +6,11 @@ import com.bonus.autoweb.UI.frame.StringHelper; import com.thoughtworks.xstream.XStream; import com.thoughtworks.xstream.io.json.JettisonMappedXmlDriver; import org.openqa.selenium.By; +import org.openqa.selenium.NoSuchElementException; import org.openqa.selenium.WebDriver; import org.openqa.selenium.WebElement; +import org.openqa.selenium.support.ui.ExpectedConditions; +import org.openqa.selenium.support.ui.WebDriverWait; import org.slf4j.Logger; import org.slf4j.LoggerFactory; @@ -16,6 +19,7 @@ import java.io.FileInputStream; import java.io.InputStreamReader; import java.nio.charset.Charset; import java.text.ParseException; +import java.time.Duration; /** * 操作值班日志类 @@ -149,7 +153,6 @@ public class DutyLogIOp { */ private void dutyLogContent() throws InterruptedException { //值班时间 -// /html/body/div[3]/div/div[2]/div/form/div[1]/div/div/div[1]/div/div/div/div webDriver.findElement(By.xpath("/html/body/div[3]/div/div[2]/div/form/div[1]/div/div/div[1]/div/div/div/div[1]")).click(); log.info("值班时间----------"); Thread.sleep(500); @@ -182,42 +185,41 @@ 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 -// 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 -// 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 -// 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 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 + 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 + 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(); - // /html/body/div[3]/div/div[2]/div/form/div[4]/table/tr[2]/td/table[1]/tr[1]/td/div[3]/div/div[1]/textarea webDriver.findElement(By.xpath("/html/body/div[3]/div/div[2]/div/form/div[4]/table/tr[2]/td/table[1]/tr[1]/td/div[3]/div/div/textarea")).sendKeys(sjjc_title); log.info("事件监测 标题----------"); Thread.sleep(1000); @@ -240,7 +242,6 @@ public class DutyLogIOp { bdgzContentElement.clear(); bdgzContentElement.sendKeys(bdgz_content.trim()); -// webDriver.findElement(By.xpath("/html/body/div[3]/div/div[2]/div/form/div[4]/table/tr[2]/td/table[2]/tr[2]/td/div/div/div[1]/textarea")).sendKeys(bdgz_content); log.info("保电工作 内容----------"); Thread.sleep(2000); @@ -253,11 +254,39 @@ public class DutyLogIOp { String zyhc_content = bean.getResource_check_content(); webDriver.findElement(By.xpath("/html/body/div[3]/div/div[2]/div/form/div[4]/table/tr[2]/td/table[3]/tr[2]/td/div/div/div/textarea")).sendKeys(zyhc_content); log.info("资源核查 内容----------"); - Thread.sleep(500); + Thread.sleep(2000); //通信测试 标题 String txcs_title = bean.getCommunications_test_title(); - webDriver.findElement(By.xpath("/html/body/div[3]/div/div[2]/div/form/div[4]/table/tr[2]/td/table[4]/tr[1]/td/div[3]/div/div/textarea")).sendKeys(txcs_title); + log.info("txcs_title:{}", txcs_title); +// WebElement element = webDriver.findElement(By.xpath("/html/body/div[3]/div/div[2]/div/form/div[4]/table/tr[2]/td/table[4]/tr[1]/td/div[3]/div/div/textarea")); + WebElement element = webDriver.findElement(By.cssSelector("body > div.el-dialog__wrapper.ecs-dialog.otherDialog.limit.no-padding.no-radius.with-footer > div > div.el-dialog__body > div > form > div.btnShow > table > tr:nth-child(2) > td > table:nth-child(4) > tr:nth-child(1) > td > div.el-form-item.addId-box-title.is-required.el-form-item--small > div > div > textarea")); + element.clear(); + element.sendKeys(txcs_title.trim()); + log.info("输入成功"); +// try { +// log.info("通信测试 走到了----------1"); +// WebDriverWait wait = new WebDriverWait(webDriver, 10); +// element = wait.until(ExpectedConditions.visibilityOfElementLocated(By.xpath("/html/body/div[3]/div/div[2]/div/form/div[4]/table/tr[2]/td/table[4]/tr[1]/td/div[3]/div/div/textarea"))); +// log.info("Element text: " + element.getText()); +// log.info("Element toString: " + element.toString()); +// if (element.isEnabled()) { +// element.sendKeys("今日开展通信测试1项,均正常"); +// log.info("输入成功"); +// } else { +// log.error("Element not enabled for input"); +// } +// +// log.info("通信测试 走到了----------2"); +// +// } catch (NoSuchElementException e) { +// log.info("通信测试 报错走catch----------1"); +// element = webDriver.findElement(By.xpath("/html/body/div[3]/div/div[2]/div/form/div[4]/table/tr[2]/td/table[4]/tr[1]/td/div[3]/div/div[1]/textarea")); +// log.info(element.getText()); +// log.info(String.valueOf(element)); +// element.sendKeys(txcs_title); +// log.info("通信测试 报错走catch----------2"); +// } log.info("通信测试 标题----------"); Thread.sleep(500); //通信测试 内容 diff --git a/src/main/resources/log4j.properties b/src/main/resources/log4j.properties index 66ea144..3c4b668 100644 --- a/src/main/resources/log4j.properties +++ b/src/main/resources/log4j.properties @@ -7,7 +7,7 @@ log4j.appender.stdout.Target = System.out log4j.appender.stdout.layout = org.apache.log4j.PatternLayout log4j.appender.stdout.layout.ConversionPattern = [%-5p] %d{yyyy-MM-dd HH:mm:ss,SSS} method:%l%n%m%n -### DEBUG ϵ־=E://logs/error.log ### +### DEBUG ϵ־=D://logs/error.log ### log4j.appender.D = org.apache.log4j.DailyRollingFileAppender log4j.appender.D.File = logs/log.log log4j.appender.D.Append = true @@ -15,7 +15,7 @@ log4j.appender.D.Threshold = DEBUG log4j.appender.D.layout = org.apache.log4j.PatternLayout log4j.appender.D.layout.ConversionPattern = %-d{yyyy-MM-dd HH:mm:ss} [ %t:%r ] - [ %p ] %m%n -### ERROR ϵ־=E://logs/error.log ### +### ERROR ϵ־=D://logs/error.log ### log4j.appender.E = org.apache.log4j.DailyRollingFileAppender log4j.appender.E.File =logs/error.log log4j.appender.E.Append = true