Skip to content

Commit

Permalink
Merge pull request #8698 from hzi-braunschweig/8657-FixPageLoadingTests
Browse files Browse the repository at this point in the history
8657 fix page loading tests
  • Loading branch information
rdutu-vg committed Apr 5, 2022
2 parents 9766659 + cc8b497 commit 8c3edae
Show file tree
Hide file tree
Showing 9 changed files with 42 additions and 19 deletions.
Expand Up @@ -50,7 +50,7 @@ public static String getUuidValueForLocale(String communityName, String locale)
CommunityValues[] communityValues = CommunityValues.values();
for (CommunityValues value : communityValues) {
if (value.name().equalsIgnoreCase(communityName)) {
if (locale.equalsIgnoreCase("main")) {
if (locale.equalsIgnoreCase("main") || locale.equalsIgnoreCase("performance")) {
return value.getUuidMain();
}
if (locale.equalsIgnoreCase("DE")) {
Expand Down
Expand Up @@ -37,7 +37,7 @@ public static String getUuidValueForLocale(String continent, String locale) {
ContinentUUIDs[] continentUUIDs = ContinentUUIDs.values();
for (ContinentUUIDs value : continentUUIDs) {
if (value.name().equalsIgnoreCase(continent)) {
if (locale.equalsIgnoreCase("main")) {
if (locale.equalsIgnoreCase("main") || locale.equalsIgnoreCase("performance")) {
return value.getUuidMain();
}
if (locale.equalsIgnoreCase("DE")) {
Expand Down
Expand Up @@ -37,7 +37,7 @@ public static String getUuidValueForLocale(String country, String locale) {
CountryUUIDs[] countryUUIDs = CountryUUIDs.values();
for (CountryUUIDs value : countryUUIDs) {
if (value.name().equalsIgnoreCase(country)) {
if (locale.equalsIgnoreCase("main")) {
if (locale.equalsIgnoreCase("main") || locale.equalsIgnoreCase("performance")) {
return value.getUuidMain();
}
if (locale.equalsIgnoreCase("DE")) {
Expand Down
Expand Up @@ -61,7 +61,7 @@ public static String getUuidValueForLocale(String districtName, String locale) {
DistrictsValues[] districtsValues = DistrictsValues.values();
for (DistrictsValues value : districtsValues) {
if (value.name().equalsIgnoreCase(districtName)) {
if (locale.equalsIgnoreCase("main")) {
if (locale.equalsIgnoreCase("main") || locale.equalsIgnoreCase("performance")) {
return value.getUuidMain();
}
if (locale.equalsIgnoreCase("DE")) {
Expand Down
Expand Up @@ -52,7 +52,7 @@ public static String getUuidValueForLocale(String regionName, String locale) {
RegionsValues[] regionValuesOptions = RegionsValues.values();
for (RegionsValues value : regionValuesOptions) {
if (value.name.equalsIgnoreCase(regionName)) {
if (locale.equalsIgnoreCase("main")) {
if (locale.equalsIgnoreCase("main") || locale.equalsIgnoreCase("performance")) {
return value.getUuidMain();
}
if (locale.equalsIgnoreCase("DE")) {
Expand Down
Expand Up @@ -37,7 +37,7 @@ public static String getUuidValueForLocale(String subContinent, String locale) {
SubcontinentUUIDs[] subContinentUUIDs = SubcontinentUUIDs.values();
for (SubcontinentUUIDs value : subContinentUUIDs) {
if (value.name().equalsIgnoreCase(subContinent)) {
if (locale.equalsIgnoreCase("main")) {
if (locale.equalsIgnoreCase("main") || locale.equalsIgnoreCase("performance")) {
return value.getUuidMain();
}
if (locale.equalsIgnoreCase("DE")) {
Expand Down
Expand Up @@ -42,7 +42,6 @@ public void assertWithPoll(ThrowingRunnable throwingRunnable, int seconds) {
.timeout(Duration.ofSeconds(seconds))
.untilAsserted(throwingRunnable);
} catch (ConditionTimeoutException e) {
log.error("Test has failed due to: {}", e.getCause());
fail(e.getCause().getLocalizedMessage());
}
}
Expand All @@ -57,7 +56,6 @@ public void assertWithPollWithoutFail(ThrowingRunnable throwingRunnable, int sec
.timeout(Duration.ofSeconds(seconds))
.untilAsserted(throwingRunnable);
} catch (ConditionTimeoutException e) {
log.error("Skipped failing assert: {}", e.getCause());
}
}

Expand Down
Expand Up @@ -812,7 +812,6 @@ public void waitForPageLoadingSpinnerToDisappear(int maxWaitingTime) {
By.xpath(
"//div[@class='v-loading-indicator third v-loading-indicator-wait' or contains(@class, 'v-loading-indicator')]");
boolean isSpinnerDisplayed;

try {
assertHelpers.assertWithPollWithoutFail(
() ->
Expand Down Expand Up @@ -851,4 +850,27 @@ public void waitForRowToBeSelected(By rowLocator) {
public void sendFile(By selector, String filePath) {
baseSteps.getDriver().findElement(selector).sendKeys(filePath);
}

public boolean isElementDisplayedAndNoLoadingSpinnerOrThrowException(By selector) {
By loadingSpinner =
By.xpath(
"//div[@class='v-loading-indicator third v-loading-indicator-wait' or contains(@class, 'v-loading-indicator')]");
try {
await()
.pollInterval(ONE_HUNDRED_MILLISECONDS)
.ignoreExceptions()
.catchUncaughtExceptions()
.timeout(ofSeconds(FLUENT_WAIT_TIMEOUT_SECONDS))
.until(
() ->
baseSteps.getDriver().findElement(selector).isDisplayed()
&& !baseSteps.getDriver().findElement(loadingSpinner).isDisplayed());
return true;
} catch (ConditionTimeoutException ignored) {
throw new NoSuchElementException(
String.format(
"Element: %s is not visible under 20 seconds or loading spinner didn't finished",
selector));
}
}
}
Expand Up @@ -209,36 +209,39 @@ public NavBarSteps(WebDriverHelpers webDriverHelpers) {
try {
switch (page) {
case ("Surveillance Dashboard"):
webDriverHelpers.isElementDisplayedIn20SecondsOrThrowException(
webDriverHelpers.isElementDisplayedAndNoLoadingSpinnerOrThrowException(
SURVEILLANCE_DASHBOARD_NAME);
break;
case ("Contacts Dashboard"):
webDriverHelpers.isElementDisplayedIn20SecondsOrThrowException(
webDriverHelpers.isElementDisplayedAndNoLoadingSpinnerOrThrowException(
CONTACTS_DASHBOARD_NAME);
break;
case ("Tasks"):
webDriverHelpers.isElementDisplayedIn20SecondsOrThrowException(
webDriverHelpers.isElementDisplayedAndNoLoadingSpinnerOrThrowException(
GENERAL_SEARCH_INPUT);
break;
case ("Persons"):
webDriverHelpers.isElementDisplayedIn20SecondsOrThrowException(
webDriverHelpers.isElementDisplayedAndNoLoadingSpinnerOrThrowException(
SEARCH_PERSON_BY_FREE_TEXT);
break;
case ("Cases"):
webDriverHelpers.isElementDisplayedIn20SecondsOrThrowException(NEW_CASE_BUTTON);
webDriverHelpers.isElementDisplayedAndNoLoadingSpinnerOrThrowException(
NEW_CASE_BUTTON);
break;
case ("Contacts"):
webDriverHelpers.isElementDisplayedIn20SecondsOrThrowException(
webDriverHelpers.isElementDisplayedAndNoLoadingSpinnerOrThrowException(
NEW_CONTACT_PAGE_BUTTON);
break;
case ("Events"):
webDriverHelpers.isElementDisplayedIn20SecondsOrThrowException(NEW_EVENT_BUTTON);
webDriverHelpers.isElementDisplayedAndNoLoadingSpinnerOrThrowException(
NEW_EVENT_BUTTON);
break;
case ("Samples"):
webDriverHelpers.isElementDisplayedIn20SecondsOrThrowException(SAMPLE_SEARCH_INPUT);
webDriverHelpers.isElementDisplayedAndNoLoadingSpinnerOrThrowException(
SAMPLE_SEARCH_INPUT);
break;
case ("Immunizations"):
webDriverHelpers.isElementDisplayedIn20SecondsOrThrowException(
webDriverHelpers.isElementDisplayedAndNoLoadingSpinnerOrThrowException(
ADD_NEW_IMMUNIZATION_BUTTON);
break;
}
Expand All @@ -249,7 +252,7 @@ public NavBarSteps(WebDriverHelpers webDriverHelpers) {
} catch (Exception exception) {
elapsedTime = "Couldn't load page under 20s";
}
log.info("Collecting test results");
log.info("Adding page [ {} ] loading results to report", page);
TableDataManager.addRowEntity(page + " page", elapsedTime);
});
}
Expand Down

0 comments on commit 8c3edae

Please sign in to comment.