This repository has been archived by the owner on Jan 14, 2019. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 167
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #336 from just-boris/master
add timeout to check hash
- Loading branch information
Showing
2 changed files
with
47 additions
and
10 deletions.
There are no files selected for viewing
39 changes: 39 additions & 0 deletions
39
allure-e2e/src/test/java/ru/yandex/qatools/allure/UrlFragmentMatcher.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,39 @@ | ||
package ru.yandex.qatools.allure; | ||
|
||
import org.hamcrest.Description; | ||
import org.hamcrest.TypeSafeMatcher; | ||
import org.openqa.selenium.WebDriver; | ||
|
||
import java.net.URI; | ||
|
||
public class UrlFragmentMatcher extends TypeSafeMatcher<WebDriver> { | ||
|
||
private String expectedFragment; | ||
|
||
public UrlFragmentMatcher(String fragment) { | ||
expectedFragment = fragment; | ||
} | ||
|
||
private String getUrlFragment(WebDriver driver) { | ||
return URI.create(driver.getCurrentUrl()).getFragment(); | ||
} | ||
|
||
@Override | ||
public void describeTo(Description description) { | ||
description.appendText("Fragment should be equal \"").appendText(expectedFragment).appendText("\""); | ||
} | ||
|
||
@Override | ||
protected void describeMismatchSafely(WebDriver driver, Description mismatchDescription) { | ||
mismatchDescription.appendText("was \"").appendText(getUrlFragment(driver)).appendText("\""); | ||
} | ||
|
||
@Override | ||
protected boolean matchesSafely(WebDriver driver) { | ||
return expectedFragment.equals(getUrlFragment(driver)); | ||
} | ||
|
||
public static UrlFragmentMatcher hasFragment(String fragment) { | ||
return new UrlFragmentMatcher(fragment); | ||
} | ||
} |
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