利辛自动化小程序
This commit is contained in:
parent
9e0ea76797
commit
b9ef498929
|
|
@ -1,5 +1,7 @@
|
|||
package com.bonus.autoweb;
|
||||
|
||||
import com.bonus.autoweb.base.DataConfig;
|
||||
|
||||
import java.text.ParseException;
|
||||
import java.text.SimpleDateFormat;
|
||||
import java.time.LocalDate;
|
||||
|
|
@ -7,7 +9,6 @@ import java.util.*;
|
|||
|
||||
/**
|
||||
* 日期操作工具类
|
||||
* @author Lenovo
|
||||
*/
|
||||
public class DateTimeUtils {
|
||||
|
||||
|
|
@ -88,16 +89,15 @@ public class DateTimeUtils {
|
|||
* 获取昨天的日期
|
||||
* @return
|
||||
*/
|
||||
public static String getLastDayYyyyMmDd(){
|
||||
public static String getLastDayYYYYMMDD(){
|
||||
SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd");
|
||||
Calendar c = Calendar.getInstance();
|
||||
//-1.昨天时间 0.当前时间 1.明天时间 *以此类推
|
||||
c.add(Calendar.DATE, -1);
|
||||
c.add(Calendar.DATE, -1);//-1.昨天时间 0.当前时间 1.明天时间 *以此类推
|
||||
String time = sdf.format(c.getTime());
|
||||
System.out.println("昨天的时间时间是:" + time);
|
||||
System.out.println("昨天的时间时间是:" + time);//20190704
|
||||
return time;
|
||||
}
|
||||
private static List<Integer> getaRandomCollectionOfData() {
|
||||
private static List<Integer> getARandomCollectionOfData() {
|
||||
Random random = new Random();
|
||||
int minCount = 3; // 最小数量
|
||||
int maxCount = 5; // 最大数量
|
||||
|
|
@ -115,6 +115,7 @@ public class DateTimeUtils {
|
|||
}
|
||||
|
||||
public static void main(String[] args) throws ParseException {
|
||||
// System.out.println(getMMDDByNow());
|
||||
//获取一个随机数据集合
|
||||
compareDate("2024-01-18","2024-01-24");
|
||||
}
|
||||
|
|
@ -157,7 +158,7 @@ public class DateTimeUtils {
|
|||
SimpleDateFormat formatter = new SimpleDateFormat("MM月dd日");
|
||||
return formatter.format(date);
|
||||
}
|
||||
public static String getmmddbynow(){
|
||||
public static String getMMDDByNow(){
|
||||
Date date=new Date();
|
||||
SimpleDateFormat formatter = new SimpleDateFormat("MMdd");
|
||||
return formatter.format(date);
|
||||
|
|
|
|||
|
|
@ -20,7 +20,6 @@ import org.slf4j.Logger;
|
|||
|
||||
/**
|
||||
* 操作值班日志类
|
||||
* @author Lenovo
|
||||
*/
|
||||
public class DutyLogIop {
|
||||
private Logger log = LoggerFactory.getLogger(DutyLogIop.class);
|
||||
|
|
@ -129,6 +128,11 @@ public class DutyLogIop {
|
|||
tr = DateTimeUtils.getWeekNum(mothDay);
|
||||
td = DateTimeUtils.getWeekOfDate(mothDay);
|
||||
xpath = "//*[@id=\"app\"]/div/section/main/div/div[1]/div[1]/div[3]/div[2]/table/tbody/tr[" + tr + "]" + "/td[" + td + "]/div";
|
||||
// String dayNum = mothDay.substring(8, 10);
|
||||
// WebElement spanElement = webDriver.findElement(By.xpath("//*[@id=\"app\"]/div/section/main/div/div[1]/div[1]/div[3]/div[2]/table/tbody/tr[" + tr + "]" + "/td[" + td + "]/div/div/div[1]/span"));
|
||||
// if (dayNum.equals(spanElement.getText())) {
|
||||
// xpath = "//*[@id=\"app\"]/div/section/main/div/div[1]/div[1]/div[3]/div[2]/table/tbody/tr[" + (tr + 1) + "]" + "/td[" + td + "]/div";
|
||||
// }
|
||||
|
||||
}
|
||||
//选择前一天的日期
|
||||
|
|
@ -154,7 +158,7 @@ public class DutyLogIop {
|
|||
Thread.sleep(500);
|
||||
|
||||
// 反序列化--> 解决乱码问题
|
||||
File file = new File(DataConfig.FILE_PATH + "\\log.xml");
|
||||
File file = new File(DataConfig.filePath + "\\log.xml");
|
||||
InputStreamReader in = null;
|
||||
String xml = null;
|
||||
try {
|
||||
|
|
@ -190,7 +194,7 @@ public class DutyLogIop {
|
|||
Thread.sleep(500);
|
||||
|
||||
//输入最低气温
|
||||
String zdqw = bean.getMinTemperature();
|
||||
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())){
|
||||
|
|
@ -201,7 +205,7 @@ public class DutyLogIop {
|
|||
Thread.sleep(500);
|
||||
|
||||
//输入最高气温
|
||||
String zgqw = bean.getMaxTemperature();
|
||||
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())){
|
||||
|
|
@ -212,97 +216,98 @@ public class DutyLogIop {
|
|||
Thread.sleep(500);
|
||||
|
||||
//事件监测 标题
|
||||
String sjjcTitle = bean.getEventDetectionTitle();
|
||||
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(sjjcTitle);
|
||||
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(500);
|
||||
//事件监测 内容
|
||||
String sjjcContent = bean.getEventDetectionContent();
|
||||
webDriver.findElement(By.xpath("/html/body/div[3]/div/div[2]/div/form/div[4]/table/tr[2]/td/table[1]/tr[2]/td/div/div/div/textarea")).sendKeys(sjjcContent);
|
||||
String sjjc_content = bean.getEvent_detection_content();
|
||||
webDriver.findElement(By.xpath("/html/body/div[3]/div/div[2]/div/form/div[4]/table/tr[2]/td/table[1]/tr[2]/td/div/div/div/textarea")).sendKeys(sjjc_content);
|
||||
log.info("事件监测 内容----------");
|
||||
Thread.sleep(500);
|
||||
|
||||
//保电工作 标题
|
||||
String bdgzTitle = bean.getPowerWorkTitle();
|
||||
webDriver.findElement(By.xpath("/html/body/div[3]/div/div[2]/div/form/div[4]/table/tr[2]/td/table[2]/tr[1]/td/div[3]/div/div/textarea")).sendKeys(bdgzTitle);
|
||||
String bdgz_title = bean.getPower_work_title();
|
||||
webDriver.findElement(By.xpath("/html/body/div[3]/div/div[2]/div/form/div[4]/table/tr[2]/td/table[2]/tr[1]/td/div[3]/div/div/textarea")).sendKeys(bdgz_title);
|
||||
log.info("保电工作 标题----------");
|
||||
Thread.sleep(2000);
|
||||
|
||||
//保电工作 内容
|
||||
String bdgzContent = bean.getPowerWorkContent();
|
||||
System.out.println("bdgz_content:" + bdgzContent);
|
||||
String bdgz_content = bean.getPower_work_content();
|
||||
System.out.println("bdgz_content:" + bdgz_content);
|
||||
WebElement bdgzContentElement = 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"));
|
||||
|
||||
bdgzContentElement.clear();
|
||||
bdgzContentElement.sendKeys(bdgzContent.trim());
|
||||
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);
|
||||
|
||||
//资源核查 标题
|
||||
String zyhcTitle = bean.getResourceCheckTitle();
|
||||
webDriver.findElement(By.xpath("/html/body/div[3]/div/div[2]/div/form/div[4]/table/tr[2]/td/table[3]/tr[1]/td/div[3]/div/div/textarea")).sendKeys(zyhcTitle);
|
||||
String zyhc_title = bean.getResource_check_title();
|
||||
webDriver.findElement(By.xpath("/html/body/div[3]/div/div[2]/div/form/div[4]/table/tr[2]/td/table[3]/tr[1]/td/div[3]/div/div/textarea")).sendKeys(zyhc_title);
|
||||
log.info("资源核查 标题----------");
|
||||
Thread.sleep(500);
|
||||
//资源核查 内容
|
||||
String zyhcContent = bean.getResourceCheckContent();
|
||||
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(zyhcContent);
|
||||
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);
|
||||
|
||||
//通信测试 标题
|
||||
String txcsTitle = bean.getCommunicationsTestTitle();
|
||||
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(txcsTitle);
|
||||
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("通信测试 标题----------");
|
||||
Thread.sleep(500);
|
||||
//通信测试 内容
|
||||
String txcsContent = bean.getCommunicationsTestContent();
|
||||
webDriver.findElement(By.xpath("/html/body/div[3]/div/div[2]/div/form/div[4]/table/tr[2]/td/table[4]/tr[2]/td/div/div/div/textarea")).sendKeys(txcsContent);
|
||||
String txcs_content = bean.getCommunications_test_content();
|
||||
webDriver.findElement(By.xpath("/html/body/div[3]/div/div[2]/div/form/div[4]/table/tr[2]/td/table[4]/tr[2]/td/div/div/div/textarea")).sendKeys(txcs_content);
|
||||
log.info("通信测试 内容----------");
|
||||
Thread.sleep(500);
|
||||
|
||||
|
||||
//日常操练情况 标题
|
||||
String rcclqkTitle = bean.getDailyOperationTitle();
|
||||
webDriver.findElement(By.xpath("/html/body/div[3]/div/div[2]/div/form/div[4]/table/tr[2]/td/table[5]/tr[1]/td/div[3]/div/div/textarea")).sendKeys(rcclqkTitle);
|
||||
String rcclqk_title = bean.getDaily_operation_title();
|
||||
webDriver.findElement(By.xpath("/html/body/div[3]/div/div[2]/div/form/div[4]/table/tr[2]/td/table[5]/tr[1]/td/div[3]/div/div/textarea")).sendKeys(rcclqk_title);
|
||||
log.info("日常操练情况 标题----------");
|
||||
Thread.sleep(500);
|
||||
//日常操练情况 内容
|
||||
String rcclqkContent = bean.getDailyOperationContent();
|
||||
webDriver.findElement(By.xpath("/html/body/div[3]/div/div[2]/div/form/div[4]/table/tr[2]/td/table[5]/tr[2]/td/div/div/div/textarea")).sendKeys(rcclqkContent);
|
||||
String rcclqk_content = bean.getDaily_operation_content();
|
||||
webDriver.findElement(By.xpath("/html/body/div[3]/div/div[2]/div/form/div[4]/table/tr[2]/td/table[5]/tr[2]/td/div/div/div/textarea")).sendKeys(rcclqk_content);
|
||||
log.info("日常操练情况 内容----------");
|
||||
Thread.sleep(500);
|
||||
|
||||
//日报填写情况 标题
|
||||
String rbtxqkTitle = bean.getDailySubmissionTitle();
|
||||
webDriver.findElement(By.xpath("/html/body/div[3]/div/div[2]/div/form/div[4]/table/tr[2]/td/table[6]/tr[1]/td/div[3]/div/div/textarea")).sendKeys(rbtxqkTitle);
|
||||
String rbtxqk_title = bean.getDaily_submission_title();
|
||||
webDriver.findElement(By.xpath("/html/body/div[3]/div/div[2]/div/form/div[4]/table/tr[2]/td/table[6]/tr[1]/td/div[3]/div/div/textarea")).sendKeys(rbtxqk_title);
|
||||
log.info("日报填写情况 标题----------");
|
||||
Thread.sleep(500);
|
||||
//日常操练情况 内容
|
||||
String rbtxqkContent = bean.getDailySubmissionContent();
|
||||
webDriver.findElement(By.xpath("/html/body/div[3]/div/div[2]/div/form/div[4]/table/tr[2]/td/table[6]/tr[2]/td/div/div/div/textarea")).sendKeys(rbtxqkContent);
|
||||
String rbtxqk_content = bean.getDaily_submission_content();
|
||||
webDriver.findElement(By.xpath("/html/body/div[3]/div/div[2]/div/form/div[4]/table/tr[2]/td/table[6]/tr[2]/td/div/div/div/textarea")).sendKeys(rbtxqk_content);
|
||||
log.info("日常操练情况 内容----------");
|
||||
Thread.sleep(500);
|
||||
|
||||
//预警处置 标题
|
||||
String yjczTitle = bean.getWarningDisposalTitle();
|
||||
webDriver.findElement(By.xpath("/html/body/div[3]/div/div[2]/div/form/div[4]/table/tr[2]/td/table[7]/tr[1]/td/div[3]/div/div/textarea")).sendKeys(yjczTitle);
|
||||
String yjcz_title = bean.getWarning_disposal_title();
|
||||
webDriver.findElement(By.xpath("/html/body/div[3]/div/div[2]/div/form/div[4]/table/tr[2]/td/table[7]/tr[1]/td/div[3]/div/div/textarea")).sendKeys(yjcz_title);
|
||||
log.info("预警处置 标题----------");
|
||||
Thread.sleep(500);
|
||||
//预警处置 内容
|
||||
String yjczContent = bean.getWarningDisposalContent();
|
||||
webDriver.findElement(By.xpath("/html/body/div[3]/div/div[2]/div/form/div[4]/table/tr[2]/td/table[7]/tr[2]/td/div/div/div/textarea")).sendKeys(yjczContent);
|
||||
String yjcz_content = bean.getWarning_disposal_content();
|
||||
webDriver.findElement(By.xpath("/html/body/div[3]/div/div[2]/div/form/div[4]/table/tr[2]/td/table[7]/tr[2]/td/div/div/div/textarea")).sendKeys(yjcz_content);
|
||||
log.info("预警处置 内容----------");
|
||||
Thread.sleep(500);
|
||||
|
||||
//一般记事 标题
|
||||
String ybjsTitle = bean.getGeneralChroniclesTitle();
|
||||
webDriver.findElement(By.xpath("/html/body/div[3]/div/div[2]/div/form/div[4]/table/tr[2]/td/table[8]/tr[1]/td/div[3]/div/div/textarea")).sendKeys(ybjsTitle);
|
||||
String ybjs_title = bean.getGeneral_chronicles_title();
|
||||
webDriver.findElement(By.xpath("/html/body/div[3]/div/div[2]/div/form/div[4]/table/tr[2]/td/table[8]/tr[1]/td/div[3]/div/div/textarea")).sendKeys(ybjs_title);
|
||||
log.info("一般记事 标题----------");
|
||||
Thread.sleep(500);
|
||||
//一般记事 内容
|
||||
String ybjsContent = bean.getGeneralChroniclesContent();
|
||||
webDriver.findElement(By.xpath("/html/body/div[3]/div/div[2]/div/form/div[4]/table/tr[2]/td/table[8]/tr[2]/td/div/div/div/textarea")).sendKeys(ybjsContent);
|
||||
String ybjs_content = bean.getGeneral_chronicles_content();
|
||||
webDriver.findElement(By.xpath("/html/body/div[3]/div/div[2]/div/form/div[4]/table/tr[2]/td/table[8]/tr[2]/td/div/div/div/textarea")).sendKeys(ybjs_content);
|
||||
log.info("一般记事 内容----------");
|
||||
Thread.sleep(500);
|
||||
|
||||
|
|
@ -323,10 +328,17 @@ public class DutyLogIop {
|
|||
|
||||
Thread.sleep(1000 * 3);
|
||||
//取消
|
||||
// webDriver.findElement(By.xpath("/html/body/div[4]/div/div[3]/button[1]")).click();
|
||||
|
||||
log.info("点击弹出框确认----------");
|
||||
Thread.sleep(500);
|
||||
|
||||
//测试 点击取消按钮
|
||||
/*webDriver.findElement(By.xpath("/html/body/div[3]/div/div[3]/div/button[1]")).click();
|
||||
log.info("点击取消----------");
|
||||
Thread.sleep(500);*/
|
||||
|
||||
|
||||
//退出当前iframe,
|
||||
webDriver.switchTo().defaultContent();
|
||||
log.info("退出当前iframe----------");
|
||||
|
|
|
|||
Loading…
Reference in New Issue