用Java selenium实现禅达快速创建任务

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)]

由于篇幅限制,文档的详解资料太全面,细节内容太多,所以只把部分知识点截图出来粗略的介绍,每个小节点里面都有更细化的内容!

本文已被CODING开源项目:【一线大厂Java面试题解析+核心总结学习笔记+最新讲解视频+实战项目源码】收录

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值