【发布时间】:2018-05-08 16:16:40
【问题描述】:
假设我想测试我的 LoginPage 功能。因此,如果我输入正确的用户名和密码,那么我将被重定向到 welcomepage.jsp。
我使用了容器管理的安全性,因此您会在 URL 中看到一些 j_security_check。
Feature: MyApp Login Feature
Validate MyApp Login Features
Scenario Outline: User logs to MyApp
Given I navigate to MyApp login page
And I enter <username> and <password>
And I click on login button
Then user entered correct username and password then they should be redirected to the proper <url>
Examples:
| username | password | url |
| correctuser | correctpassword | welcome.jsp |
我的问题是如何处理 302 重定向。 如果我在浏览器中查看我的网络选项卡,我会看到以下序列
- POST j_security_check
-
获取welcome.jsp
@Then("^Then user entered correct username and password then they should be redirected to the proper ([^\"]*)$") public void user_should_be_redirected_to_the_proper(String expectedURL) throws Throwable { System.out.println("expectedURL :: " + expectedURL ); if (driver.getCurrentUrl().contains(expectedURL)) { System.out.println("MyApp Test Pass"); } else { System.out.println("MyApp Test Failed"); Assert.fail("MyApp Test failed!"); } }
我在这里看到了一些类似的问题 JavaScript Executor in Selenium WebDriver
但我认为这不是 AJAX 调用,因为我们正在等待 DOM 就绪
【问题讨论】:
标签: java selenium selenium-webdriver cucumber selenium-chromedriver