-
Notifications
You must be signed in to change notification settings - Fork 827
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
refactor: use page objects for favicon test
* The purpose of this test was difficult to understand until I removed the code that fixed the bug that this test is testing for. * It should now be easier to understand why this test exists.
- Loading branch information
1 parent
177c93f
commit d0f53e9
Showing
2 changed files
with
30 additions
and
2 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
24 changes: 24 additions & 0 deletions
24
uaa/src/test/java/org/cloudfoundry/identity/uaa/integration/pageObjects/FaviconElement.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,24 @@ | ||
package org.cloudfoundry.identity.uaa.integration.pageObjects; | ||
|
||
import org.hamcrest.Matchers; | ||
import org.openqa.selenium.WebDriver; | ||
|
||
import static org.hamcrest.Matchers.endsWith; | ||
import static org.junit.Assert.assertThat; | ||
|
||
public class FaviconElement extends Page { | ||
|
||
// The favicon.ico URL is not present on the server because we specify a custom icon URL | ||
// in the headers, but browsers try to hit it and tests need to hit this default URL. | ||
static public FaviconElement getDefaultIcon(WebDriver driver, String baseUrl) { | ||
driver.get(baseUrl + "/favicon.ico"); | ||
return new FaviconElement(driver); | ||
} | ||
|
||
// Expect a 404 error when landing on the favicon URL. | ||
public FaviconElement(WebDriver driver) { | ||
super(driver); | ||
assertThat("Should be on the favicon image", driver.getCurrentUrl(), endsWith("/favicon.ico")); | ||
assertThat(driver.getPageSource(), Matchers.containsString("Something went amiss.")); | ||
} | ||
} |