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

文章详细描述了一个Java开发者在使用禅道工具时的操作过程,包括任务创建、项目选择、人员指派以及自动化测试,同时也提及了获取token和登录的步骤。此外,还提到了作者分享的学习资源和面试经验对Java开发者的帮助。
摘要由CSDN通过智能技术生成

private static String taskName = “生产管控-开掘进度和回采进度接口测试和修改”;

//内容描述

private static String content = “”;

//任务类型 (必须和禅道任务类型一致)

private static String taskType = “开发”;

//任务指派人(L首个汉字的拼音首字母大写)

private static String people = “L:刘德华”;

//预估时长

private static String estimate = “8”;

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

自我介绍一下,小编13年上海交大毕业,曾经在小公司待过,也去过华为、OPPO等大厂,18年进入阿里一直到现在。

深知大多数Java工程师,想要提升技能,往往是自己摸索成长或者是报班学习,但对于培训机构动则几千的学费,着实压力不小。自己不成体系的自学效果低效又漫长,而且极易碰到天花板技术停滞不前!

因此收集整理了一份《2024年Java开发全套学习资料》,初衷也很简单,就是希望能够帮助到想自学提升又不知道该从何学起的朋友,同时减轻大家的负担。img

既有适合小白学习的零基础资料,也有适合3年以上经验的小伙伴深入学习提升的进阶课程,基本涵盖了95%以上Java开发知识点,真正体系化!

由于文件比较大,这里只是将部分目录截图出来,每个节点里面都包含大厂面经、学习笔记、源码讲义、实战项目、讲解视频,并且会持续更新!

如果你觉得这些内容对你有帮助,可以扫码获取!!(备注Java获取)

img

最后总结我的面试经验

2021年的金三银四一眨眼就到了,对于很多人来说是跳槽的好机会,大厂面试远没有我们想的那么困难,摆好心态,做好准备,你也可以的。

另外,面试中遇到不会的问题不妨尝试讲讲自己的思路,因为有些问题不是考察我们的编程能力,而是逻辑思维表达能力;最后平时要进行自我分析与评价,做好职业规划,不断摸索,提高自己的编程能力和抽象思维能力。

BAT面试经验

实战系列:Spring全家桶+Redis等

其他相关的电子书:源码+调优

面试真题:


《互联网大厂面试真题解析、进阶开发核心学习笔记、全套讲解视频、实战项目源码讲义》点击传送门即可获取!
33)]

其他相关的电子书:源码+调优

[外链图片转存中…(img-tEfCeTiu-1713771235033)]

面试真题:

[外链图片转存中…(img-HIgCTceT-1713771235034)]

[外链图片转存中…(img-6A726T9V-1713771235034)]
《互联网大厂面试真题解析、进阶开发核心学习笔记、全套讲解视频、实战项目源码讲义》点击传送门即可获取!

  • 4
    点赞
  • 4
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值