我是 Selenium Tools 和使用 JSF Pages 开发 JEE9 应用程序的新手。在用 Java 编写集成测试时(使用 Selenium IDE 进行记录后) - 我无法弄清楚如何在成功登录后获取用户主页: 以下是我的测试代码:
driver.get("http://localhost:8080/<app-name>/");
driver.manage().window().setSize(new Dimension(1850, 1053));
driver.findElement(By.linkText("Log In")).click();
driver.findElement(By.id("email")).sendKeys("<correct email>");
driver.findElement(By.id("password")).sendKeys("<correct password>");
driver.findElement(By.id("logInBtn")).click();
我在浏览器上的实际场景(登录成功后),应用程序重定向到用户的主页:
http://localhost:8080/<app-name>/userHome.xhtml
我的问题是如何在我的测试用例中模拟相同的行为?
我在互联网上搜索并通过 WebDriver API 都是徒劳的。
您可以在登录后使用以下代码获取URL
System.out.println(driver.getCurrentUrl());