dead code?

public static void main(String[] args) {
DriverBase dbase = new DriverBase();


dbase.driverBase();
driver.get("http://erp2.hk.com/#/login");

WebElement usernameElement= driver.findElement(By.name("user"));
usernameElement.isDisplayed();

WebElement passwordElement =driver.findElement(By.name("password"));
passwordElement.isDisplayed();

WebElement loginBtnElement =driver.findElement(By.name("login"));
loginBtnElement.isDisplayed();

usernameElement.sendKeys("UUSadmin");
passwordElement.sendKeys("123");
loginBtnElement.click();

// 智能等待
driver.manage().timeouts().implicitlyWait(3, TimeUnit.SECONDS);




WebElement headerElement = driver.findElement(By.className("name-area"));
headerElement.isDisplayed();


/*
* 鼠标点击事件,driver移动到
* */
Actions action =new Actions(driver);
action.moveToElement(headerElement).perform();

driver.manage().timeouts().implicitlyWait(3, TimeUnit.SECONDS);
////*[@classname="info"]/span[1]

//WebElement userinfoElement =driver.findElement(By.cssSelector("*[@classname='info']/span[1]"));
//String userinfo = userinfoElement.getText();

//*[@id="dropdown-menu-3003"]/div[1]/div[2]/span[1]

if(headerElement!= null) {
System.out.println("登录成功!");
dbase.closeDriver();
}else{


System.out.println("登录失败!");
//dbase.closeDriver();

}

 

//这里提示dead code,顾名思义, 程序编译时就知道这段是不会被执行的。可有可无。

 


}

 

posted @ 2020-04-23 14:47  wenna-  阅读(147)  评论(0编辑  收藏  举报