static {
ResourceBundle rb = ResourceBundle.getBundle(“zenTao”);
username = rb.getString(“zenTao.username”);
password = rb.getString(“zenTao.password”);
}
public static void main(String[] args) {
start();
}
public static void start() {
System.setProperty(webDriver, webDriverPath);
try {
if (Objects.isNull(driver)){
driver = new ChromeDriver();
userLogin(driver);
}
work(driver);
} catch (Exception e) {
e.printStackTrace();
} finally {
if (Objects.nonNull(driver)) {
// driver.close();
}
}
}
/**
- 开始工作
*/
private static void work(WebDriver driver) throws Exception {
WebElement projectButtonWebElement = driver.findElement(By.xpath(“//li[@data-id=‘project’]/a”));
projectButtonWebElement.click();
WebElement taskButtonWebElement = driver.findElement(By.xpath(“//li[@data-id=‘task’]/a”));
taskButtonWebElement.click();
WebElement createWebElement = driver.findElement(By.xpath(“//div[@id=‘mainMenu’]/div[@class=‘btn-toolbar pull-right’]/a[@class=‘btn btn-primary’]”));
createWebElement.click();
WebElement projectWebElement = driver.findElement(By.xpath(“//*[@id=‘project_chosen’]/a”));
projectWebElement.click();
Thread.sleep(200);//等待0.2秒
projectWebElement.findElement(By.xpath(“//li[@title='”+projectName+“']”)).click();
WebElement typeWebElement = driver.findElement(By.xpath(“//*[@id=‘type_chosen’]/a”));
typeWebElement.click();
Thread.sleep(200);//等待0.2秒
typeWebElement.findElement(By.xpath(“//li[@title='”+taskType+“']”)).click();
WebElement peopleWebElement = driver.findElement(By.xpath(“//*[@id=‘assignedTo_chosen’]/a”));
peopleWebElement.click();
Thread.sleep(200);//等待0.2秒
peopleWebElement.findElement(By.xpath(“//li[@title='”+people+“']”)).click();
WebElement taskWebElement = driver.findElement(By.name(“name”));
taskWebElement.sendKeys(taskName);
WebElement estimateWebElement = driver.findElement(By.name(“estimate”));
estimateWebElement.sendKeys(estimate);
WebElement contentWebElement = driver.findElement(By.xpath(“//div[@class=‘ke-edit’]/iframe”));
contentWebElement.sendKeys(content);
WebElement submitWebElement = driver.findElement(By.id(“submit”));
submitWebElement.click();
Thread.sleep(2000);//等待0.5秒
List taskList= driver.findElements(By.xpath(“//table[@id=‘taskList’]/tbody/tr”));
String id=taskList.get(0).getAttribute(“data-id”);
String name=taskList.get(0).findElements(By.tagName(“td”)).get(2).getAttribute(“title”);
System.out.println(“task#”+id+" "+name);
}
/**
- 获取token
*/
private static String getToken(WebDriver driver) throws Exception {
if (StringUtils.isBlank(driver.getCurrentUrl())) {
throw new Exception(“获取token链接有误”);
}
String token = driver.getCurrentUrl().split(“token=”)[1];
if (StringUtils.isBlank(token)) {
throw new Exception(“token错误”);
}
return token;
}
/**
- 登录模块
*/
private static void userLogin(WebDriver driver) throws Exception {
driver.get(targetPath);
WebElement usernameWebElement = driver.findElement(By.name(“account”));
usernameWebElement.clear();
usernameWebElement.sendKeys(username);
WebElement passwordWebElement = driver.findElement(By.name(“password”));
passwordWebElement.clear();
passwordWebElement.sendKeys(password);
WebElement helpWebElement = driver.findElement(By.id(“keepLoginon”));
最后
经过日积月累, 以下是小编归纳整理的深入了解Java虚拟机文档,希望可以帮助大家过关斩将顺利通过面试。
由于整个文档比较全面,内容比较多,篇幅不允许,下面以截图方式展示 。
由于篇幅限制,文档的详解资料太全面,细节内容太多,所以只把部分知识点截图出来粗略的介绍,每个小节点里面都有更细化的内容!
[外链图片转存中…(img-sL5DAcbB-1714761072481)]
[外链图片转存中…(img-yaSFZupB-1714761072481)]
[外链图片转存中…(img-KNBKhdig-1714761072481)]
[外链图片转存中…(img-3TmiJG7I-1714761072481)]
由于篇幅限制,文档的详解资料太全面,细节内容太多,所以只把部分知识点截图出来粗略的介绍,每个小节点里面都有更细化的内容!