新建一个LoginCase类,先线性代码实现单个登录功能
public class LoginTest { public static void main(String[] args) { WebDriverUtils.openBrower("chrome"); WebDriver d = WebDriverUtils.driver; d.get("登录测试地址url"); d.findElement(By.name("phone")).sendKeys("有效用户名"); d.findElement(By.name("password")).sendKeys("有效密码"); d.findElement(By.xpath("//button[text()='登录']")).click(); //显示等待应用 WebDriverWait w = new WebDriverWait(d, 5); try { w.until(ExpectedConditions.invisibilityOfElementLocated(By.xpath("//button[text()='退出']"))); System.out.println("测试通过"); } catch (Exception e) { System.out.println("测试不通过"); } } }