public static class SeleniumHelper.Companion
| Modifier and Type | Method and Description |
|---|---|
org.openqa.selenium.support.ui.ExpectedCondition<java.lang.Boolean> |
absenceOfWebElement(org.openqa.selenium.WebElement webElement)
Allows to check for the absence of a web element. See
https://stackoverflow.com/questions/6533597/webdriver-how-to-check-if-an-page-object-web-element-exists
which is referencing
https://groups.google.com/forum/#!topic/webdriver/kJqbbLVo40E for an
explanation why this is a good if not the only way to perform the check.
|
void |
assertResponseCodeEquals(int responseCode,
org.apache.http.HttpResponse httpResponse)
Compares the response code of
uRLConnection to
responseCode |
void |
assertResponseCodeEquals(int responseCode,
java.net.HttpURLConnection uRLConnection)
Compares the response code of
uRLConnection to
responseCode |
java.util.Set<java.util.List> |
createMessagePermutation(java.util.Collection<java.lang.String> texts)
Creates the permutation of
texts which might be useful in
.assertMessagesContainsAny
in order to reflect that validation constraint violoations are generally
in undefined order since Validator.validate returns a
Set.This methods creates n faculty (n!) items for n
items in text which can take a long time to check (five items can
already take up to a minute). |
java.util.Set<java.util.List> |
createMessagePermutation(java.lang.String texts) |
com.natpryce.hamkrest.Matcher<de.richtercloud.jsf.validation.service.ValidatorMessage> |
getMISSING_DOCTYPE_MESSAGE_MATCHER()
Accounts for the fact that some Selenium driver implementations don't include the doctype in their page source
return value, but we might want to evaluate the driver's page source rather than the real page's source.
|
java.lang.String |
randomString(int length)
Wrapper around random string generation which allows to quickly avoid
temporary problems like Chrome Selenium driver not accepting unicode
characters outside Basic Multilingual Plane (BMP) (asked
https://stackoverflow.com/questions/46950897/how-to-produce-random-basic-multilingual-plane-bmp-strings-in-java
for inputs)
|
java.lang.String |
retrievePlainText(org.openqa.selenium.WebDriver browser) |
org.openqa.selenium.WebElement |
retrieveSlideMenuItem(org.openqa.selenium.WebElement slideMenu,
int indices)
Retrieves a specific menu item in the nested submenus opened based on the
specified indices assuming that all menu items are links.
|
java.util.List<org.openqa.selenium.WebElement> |
retrieveSlideMenuItems(org.openqa.selenium.WebElement slideMenu,
int indices)
Retrieves all menu items in the nested submenus opened based on the
specified indices assuming that all menu items are links.
|
public com.natpryce.hamkrest.Matcher<de.richtercloud.jsf.validation.service.ValidatorMessage> getMISSING_DOCTYPE_MESSAGE_MATCHER()
Accounts for the fact that some Selenium driver implementations don't include the doctype in their page source return value, but we might want to evaluate the driver's page source rather than the real page's source.
public java.lang.String randomString(int length)
Wrapper around random string generation which allows to quickly avoid temporary problems like Chrome Selenium driver not accepting unicode characters outside Basic Multilingual Plane (BMP) (asked https://stackoverflow.com/questions/46950897/how-to-produce-random-basic-multilingual-plane-bmp-strings-in-java for inputs)
length - the length of the produced stringpublic java.lang.String retrievePlainText(org.openqa.selenium.WebDriver browser)
public java.util.Set<java.util.List> createMessagePermutation(java.util.Collection<java.lang.String> texts)
Creates the permutation of texts which might be useful in
.assertMessagesContainsAny
in order to reflect that validation constraint violoations are generally
in undefined order since Validator.validate returns a
Set.This methods creates n faculty (n!) items for n
items in text which can take a long time to check (five items can
already take up to a minute).
Note that the type of the collection used for texts determines
whether the return value contains the item more than once or not.
An example for steam fetichist (involving SteamEx stream extension): `createMessagePermutation(StreamEx.of(entities.stream()) .map(prop -> String.format("invalid: key '%s' mustn't be mapped to null", prop.getName())) .append("invalid: mapping for this entity isn't valid. Details should have been given to you.") .collect(Collectors.toSet())) .stream() .map(perm -> StreamEx.of(perm) .joining("\n", String.format("%s\n"
"The following constraints are violated:\n", BackingBean.X_FAILED_ERROR_SUMMARY), String.format("\nFix the corresponding values in the components."))) //joining isn't necessary because \n could have been //added to each of the permutation items, this was //used as a way to get to know the awesome StreamEx //library .collect(Collectors.toSet()); ` *
texts - the texts to permutatepublic java.util.Set<java.util.List> createMessagePermutation(java.lang.String texts)
public void assertResponseCodeEquals(int responseCode,
org.apache.http.HttpResponse httpResponse)
Compares the response code of uRLConnection to
responseCode
Don't use JUnit 5 Assertions.fail or other methods since they confuse jqwik tests
responseCode - the expected response codehttpResponse - the response to checkresponseCodepublic void assertResponseCodeEquals(int responseCode,
java.net.HttpURLConnection uRLConnection)
Compares the response code of uRLConnection to
responseCode
Don't use JUnit 5 Assertions.fail or other methods since they confuse jqwik tests
responseCode - the expected response codeuRLConnection - the connection to checkresponseCodepublic org.openqa.selenium.WebElement retrieveSlideMenuItem(org.openqa.selenium.WebElement slideMenu,
int indices)
Retrieves a specific menu item in the nested submenus opened based on the specified indices assuming that all menu items are links.
slideMenu - the slide menu elementindices - the indices of submenus to openpublic java.util.List<org.openqa.selenium.WebElement> retrieveSlideMenuItems(org.openqa.selenium.WebElement slideMenu,
int indices)
Retrieves all menu items in the nested submenus opened based on the specified indices assuming that all menu items are links.
slideMenu - the slide menu elementindices - the indices of submenus to openpublic org.openqa.selenium.support.ui.ExpectedCondition<java.lang.Boolean> absenceOfWebElement(org.openqa.selenium.WebElement webElement)
Allows to check for the absence of a web element. See https://stackoverflow.com/questions/6533597/webdriver-how-to-check-if-an-page-object-web-element-exists which is referencing https://groups.google.com/forum/#!topic/webdriver/kJqbbLVo40E for an explanation why this is a good if not the only way to perform the check.
webElement - the web element whose absence to check