【发布时间】:2015-08-24 10:28:30
【问题描述】:
有没有办法简化下面的代码?
public static void InputData(){
//Lastname
if (driver.findElements(By.id("last_name")).size() != 0) {
driver.findElement(By.id("last_name")).sendKeys("MARSUPIAL");
}
//Fistname
if (driver.findElements(By.id("first_name")).size() != 0) {
driver.findElement(By.id("first_name")).sendKeys("MARK");
}
}
我有 20 件物品具有相同的“如果”场景
有没有办法在单个 if 语句中编写它而不是在每个文本框中执行“如果对象存在写入 'x'”?
提前致谢
【问题讨论】:
标签: java selenium if-statement automation webdriver