refactor(website): 更新网站 URL 并调整页面元素定位策略- 更新 DataConfig 类中的 URL常量
- 调整 DutyDailyCheck、DutyDailyOp 和 DutyLogIOp 类中的页面元素定位路径 - 优化 GetBasicData 类中的执行计划方法,增加对上月日历的处理逻辑 - 修改 TestMain 类中的线程启动方式
This commit is contained in:
parent
54b5ed13b1
commit
76aa2575f6
|
|
@ -1077,7 +1077,7 @@ public class GetBasicData {
|
||||||
// String projectName = "通信";
|
// String projectName = "通信";
|
||||||
//执行计划
|
//执行计划
|
||||||
// try {
|
// try {
|
||||||
executePlan(type, company, "");
|
executePlan(type, company, "", code);
|
||||||
// }catch (Exception e){
|
// }catch (Exception e){
|
||||||
// while (true){
|
// 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"));
|
// 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,12 +1088,14 @@ 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);
|
Thread.sleep(5000);
|
||||||
|
webDriver.findElement(By.xpath("//*[@id=\"pane-sec\"]/section/header/form/div[1]/div[8]/div/div/button[2]")).click();
|
||||||
|
Thread.sleep(10000);
|
||||||
String checkContent = resolveGarbledCode("E:\\bns\\config\\检查计划评价.txt");
|
String checkContent = resolveGarbledCode("E:\\bns\\config\\检查计划评价.txt");
|
||||||
String[] checkContentArrayArray = checkContent.split("检查评价:");
|
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();
|
webDriver.findElement(By.xpath("//*[@id=\"pane-sec\"]/section/main/section/main/div/div[3]/table/tbody/tr[1]")).click();
|
||||||
Thread.sleep(800);
|
Thread.sleep(800);
|
||||||
//点击执行按钮--打开选择被检查对象
|
//点击执行按钮--打开选择被检查对象
|
||||||
webDriver.findElement(By.xpath("/html/body/div[1]/section/div[1]/div[2]/div[2]/section/main/section/header/button[4]")).click();
|
webDriver.findElement(By.xpath("/html/body/div[1]/section/div[1]/div[2]/div[2]/section/main/section/header/button[4]")).click();
|
||||||
|
|
@ -1215,31 +1217,19 @@ public class GetBasicData {
|
||||||
webDriver.findElement(By.xpath("/html/body/div[3]/div/div[2]/section/header/form/div/div[4]/div/div[2]")).click();
|
webDriver.findElement(By.xpath("/html/body/div[3]/div/div[2]/section/header/form/div/div[4]/div/div[2]")).click();
|
||||||
log.info("点击选择被检查单位型选择框-----------");
|
log.info("点击选择被检查单位型选择框-----------");
|
||||||
Thread.sleep(1000);
|
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[2]/div["+code+"]/div/span[2]")).click();
|
||||||
|
webDriver.findElement(By.xpath("/html/body/div[3]/div/div[2]/section/header/form/div/div[4]/div/div[2]")).click();
|
||||||
log.info("选择被检查单位----------");
|
log.info("选择被检查单位----------");
|
||||||
Thread.sleep(500);
|
Thread.sleep(500);
|
||||||
//选择被检查对象
|
//选择被检查对象
|
||||||
webDriver.findElement(By.xpath("/html/body/div[3]/div/div[2]/section/header/form/div/div[5]/div/div[2]")).click();
|
webDriver.findElement(By.xpath("/html/body/div[6]/div[1]/div/div/div[1]/div[1]/span[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();
|
|
||||||
}else {
|
|
||||||
for (int i = 1; i < 9; 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);
|
|
||||||
}
|
|
||||||
Thread.sleep(3000);
|
|
||||||
webDriver.findElement(By.xpath("/html/body/div[7]/div/div[2]/section/footer[2]/button[2]")).click();
|
|
||||||
}
|
|
||||||
Thread.sleep(2000);
|
Thread.sleep(2000);
|
||||||
//提交
|
//提交
|
||||||
webDriver.findElement(By.xpath("/html/body/div[2]/div/div[2]/section/div/button[3]")).click();
|
try {
|
||||||
|
webDriver.findElement(By.xpath("/html/body/div[4]/div/div[2]/section/div/button[3]")).click();
|
||||||
|
} catch (Exception e) {
|
||||||
|
webDriver.findElement(By.xpath("/html/body/div[3]/div/div[2]/section/div/button[3]")).click();
|
||||||
|
}
|
||||||
Thread.sleep(3000);
|
Thread.sleep(3000);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -38,22 +38,22 @@ public class TestMain {
|
||||||
// testqd();
|
// testqd();
|
||||||
// testjjb();
|
// testjjb();
|
||||||
// testGetData();
|
// testGetData();
|
||||||
testAccounters();
|
// testAccounters();
|
||||||
// testDailrb();
|
// testDailrb();
|
||||||
// testRCCL();
|
// testRCCL();
|
||||||
// testLog();
|
// testLog();
|
||||||
// new Thread(new Runnable() {
|
new Thread(new Runnable() {
|
||||||
// @SneakyThrows
|
@SneakyThrows
|
||||||
// @Override
|
@Override
|
||||||
// public void run() {
|
public void run() {
|
||||||
// try {
|
try {
|
||||||
// new TestMain().autoJob();
|
new TestMain().autoJob();
|
||||||
// } catch (Exception e) {
|
} catch (Exception e) {
|
||||||
// e.printStackTrace();
|
e.printStackTrace();
|
||||||
// log.error("错误信息", e);
|
log.error("错误信息", e);
|
||||||
// }
|
}
|
||||||
// }
|
}
|
||||||
// }).start();
|
}).start();
|
||||||
}
|
}
|
||||||
|
|
||||||
private static void testAccounters() {
|
private static void testAccounters() {
|
||||||
|
|
|
||||||
|
|
@ -4,7 +4,7 @@ public class DataConfig {
|
||||||
/**
|
/**
|
||||||
* url 网站地址
|
* url 网站地址
|
||||||
*/
|
*/
|
||||||
protected static final String URL = "http://20.50.16.10/ecs/#/yjtsgz";
|
protected static final String URL = "http://xydyjzh.ah.sgcc.com.cn";
|
||||||
/**
|
/**
|
||||||
* 驱动名称
|
* 驱动名称
|
||||||
*/
|
*/
|
||||||
|
|
|
||||||
|
|
@ -37,9 +37,9 @@ public class DutyDailyCheck {
|
||||||
String checkXpath;
|
String checkXpath;
|
||||||
//早报
|
//早报
|
||||||
if(type ==1){
|
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{
|
}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]";
|
||||||
}
|
}
|
||||||
|
|
||||||
//点击审核按钮
|
//点击审核按钮
|
||||||
|
|
|
||||||
|
|
@ -49,9 +49,9 @@ public class DutyDailyOp {
|
||||||
Thread.sleep(500);
|
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) {
|
if (type == 1) {
|
||||||
webDriver.findElement(By.xpath(zaoBxPath)).click();
|
webDriver.findElement(By.xpath(zaoBxPath)).click();
|
||||||
} else {
|
} else {
|
||||||
|
|
|
||||||
|
|
@ -16,6 +16,7 @@ import java.io.FileInputStream;
|
||||||
import java.io.InputStreamReader;
|
import java.io.InputStreamReader;
|
||||||
import java.nio.charset.Charset;
|
import java.nio.charset.Charset;
|
||||||
import java.text.ParseException;
|
import java.text.ParseException;
|
||||||
|
import java.util.Calendar;
|
||||||
|
|
||||||
import org.slf4j.Logger;
|
import org.slf4j.Logger;
|
||||||
|
|
||||||
|
|
@ -125,15 +126,17 @@ public class DutyLogIOp {
|
||||||
|
|
||||||
//获取上月最后一天日期
|
//获取上月最后一天日期
|
||||||
String mothDay = DateTimeUtils.getBeforeLastMonthdate();
|
String mothDay = DateTimeUtils.getBeforeLastMonthdate();
|
||||||
//判断上个月最后一天的位置
|
// 判断上个月最后一天的位置
|
||||||
tr = DateTimeUtils.getWeekNum(mothDay);
|
int weekNum = DateTimeUtils.getWeekNum(mothDay);
|
||||||
td = DateTimeUtils.getWeekOfDate(mothDay);
|
int dayNum = DateTimeUtils.getWeekOfDate(mothDay);
|
||||||
|
// 获取上月最后一天在日历中的位置
|
||||||
|
if (isFirstDayOfLastMonthSunday()) {
|
||||||
|
tr = weekNum + 1;
|
||||||
|
} else {
|
||||||
|
tr = weekNum;
|
||||||
|
}
|
||||||
|
td = dayNum;
|
||||||
xpath = "//*[@id=\"app\"]/div/section/main/div/div[1]/div[1]/div[3]/div[2]/table/tbody/tr[" + tr + "]" + "/td[" + td + "]/div";
|
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";
|
|
||||||
// }
|
|
||||||
|
|
||||||
}
|
}
|
||||||
//选择前一天的日期
|
//选择前一天的日期
|
||||||
|
|
@ -144,6 +147,14 @@ public class DutyLogIOp {
|
||||||
log.info("选择前一天的日期----------");
|
log.info("选择前一天的日期----------");
|
||||||
Thread.sleep(500);
|
Thread.sleep(500);
|
||||||
}
|
}
|
||||||
|
public static boolean isFirstDayOfLastMonthSunday() {
|
||||||
|
Calendar calendar = Calendar.getInstance();
|
||||||
|
calendar.add(Calendar.MONTH, -1); // Move to the previous month
|
||||||
|
calendar.set(Calendar.DAY_OF_MONTH, 1); // Set to the first day of the month
|
||||||
|
|
||||||
|
int dayOfWeek = calendar.get(Calendar.DAY_OF_WEEK);
|
||||||
|
return dayOfWeek == Calendar.SUNDAY;
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 内容填写
|
* 内容填写
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue