Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
20 changes: 0 additions & 20 deletions src/org/labkey/test/Locator.java
Original file line number Diff line number Diff line change
Expand Up @@ -689,11 +689,6 @@ public static XPathLocator linkWithImage(String image)
return tag("a").withChild(tag("img").withAttributeContaining("src", image));
}

public static XPathLocator gwtButton(String text)
{
return tag("a").withClass("gwt-Anchor").withText(text);
}

public static XPathLocator button(String text)
{
return tag("button").notHidden().withPredicate("not(contains(@class, 'tab'))").withText(text);
Expand Down Expand Up @@ -907,21 +902,6 @@ public static XPathLocator lookupLink(String schemaName, String queryName, Strin
return tagWithClass("span", "labkey-link").containing(linkText);
}

public static XPathLocator gwtTextBoxByLabel(String label)
{
return tagWithClass("input", "gwt-TextBox").withPredicate(xpath("../preceding-sibling::td").withText(label));
}

public static XPathLocator gwtListBoxByLabel(String label)
{
return tagWithClass("select", "gwt-ListBox").withPredicate(xpath("../preceding-sibling::label").withText(label));
}

public static XPathLocator gwtCheckBoxOnImportGridByColLabel(String label)
{
return tagWithAttribute("input", "type", "checkbox").withPredicate(xpath("../../following-sibling::td/span").containing(label));
}

public static Locator permissionRendered()
{
return Locators.pageSignal("policyRendered");
Expand Down
6 changes: 2 additions & 4 deletions src/org/labkey/test/WebDriverWrapper.java
Original file line number Diff line number Diff line change
Expand Up @@ -3260,8 +3260,6 @@ public WebElement findButton(String text)
Locator.extButton(text),
// normal HTML button:
Locator.button(text),
// GWT button:
Locator.gwtButton(text),
// bootstrap button
BootstrapLocators.button(text)
);
Expand Down Expand Up @@ -3519,8 +3517,8 @@ else if (text.length() < 1000 && !text.contains("\n") && !text.contains("\t"))
try
{
String elementClass = input.getAttribute("class");
if (elementClass.contains("gwt-TextBox") || elementClass.contains("gwt-TextArea") || elementClass.contains("x-form-text"))
fireEvent(input, SeleniumEvent.blur); // Make GWT and ExtJS form elements behave better
if (elementClass.contains("x-form-text"))
fireEvent(input, SeleniumEvent.blur); // Make ExtJS form elements behave better
}
catch(StaleElementReferenceException stale)
{
Expand Down
48 changes: 13 additions & 35 deletions src/org/labkey/test/util/Crawler.java
Original file line number Diff line number Diff line change
Expand Up @@ -947,7 +947,7 @@ else if (downloadDir.isDirectory()) // Don't check for download if dir doesn't e
{
File[] filesArray = WebDriverWrapper.getNewFiles(0, downloadDir, existingDownloads);
downloadedFiles.setValue(filesArray);
if (downloadedFiles.getValue().length > 0)
if (downloadedFiles.get().length > 0)
{
navigated.setValue(false); // Don't wait for page load when a download occurs
return true; // Stop waiting
Expand All @@ -966,24 +966,24 @@ else if (downloadDir.isDirectory()) // Don't check for download if dir doesn't e
{
TestLogger.warn("URL didn't trigger a download or navigation: " + fullURL);
}
return navigated.getValue();
return navigated.get();
});

if (!navigated.getValue())
if (!navigated.get())
{
logMessage = logMessage.replace(messagePrefix, "Downloading from ");
}

logMessage += TestLogger.formatElapsedTime(elapsedTime);

return navigated.getValue();
return navigated.get();
}
finally
{
TestLogger.info(logMessage); // log after navigation to
if (downloadedFiles.getValue() != null)
if (downloadedFiles.get() != null)
{
Arrays.stream(downloadedFiles.getValue()).forEach(file -> {
Arrays.stream(downloadedFiles.get()).forEach(file -> {
TestLogger.info(" \u2517" + file.getName()); // Log downloaded files
FileUtils.deleteQuietly(file); // Clean up crawled downloads
});
Expand All @@ -996,7 +996,7 @@ private List<UrlToCheck> crawlLink(final UrlToCheck urlToCheck)
String relativeURL = urlToCheck.getRelativeURL();
ControllerActionId actionId = new ControllerActionId(relativeURL);
URL actualUrl; // URL might redirect
boolean navigated = true; // URL might download
boolean navigated; // URL might download
List<UrlToCheck> newUrlsToCheck = new ArrayList<>();

// Keep track of where crawler has been
Expand All @@ -1010,15 +1010,7 @@ private List<UrlToCheck> crawlLink(final UrlToCheck urlToCheck)

try
{
try
{
navigated = beginAt(relativeURL);
}
catch (UnhandledAlertException alert)
{
if (isRealFailure(alert))
throw alert;
}
navigated = beginAt(relativeURL);

if (navigated) // These checks were already performed if navigation didn't occur
{
Expand Down Expand Up @@ -1059,7 +1051,7 @@ private List<UrlToCheck> crawlLink(final UrlToCheck urlToCheck)
List<String> serverError = _test.getTexts(Locator.css("table.server-error").findElements(_test.getDriver()));
if (!serverError.isEmpty())
{
String[] errorLines = serverError.get(0).split("\n");
String[] errorLines = serverError.getFirst().split("\n");
fail(relativeURL + "\nproduced error: \"" + errorLines[0] + "\"." + originMessage);
}

Expand Down Expand Up @@ -1270,7 +1262,7 @@ protected void checkForForbiddenWords(String relativeURL)

public static void tryInject(WebDriverWrapper test, Runnable r)
{
tryInject(test, arg -> {r.run(); return true;}, null);
tryInject(test, _ -> {r.run(); return true;}, null);
}

/**
Expand Down Expand Up @@ -1342,15 +1334,6 @@ else if (responseCode == 400 && !test.onLabKeyPage())
}
}

/** Ignore GWT alerts from designer pages */
private boolean isRealFailure(Exception e)
{
return !(e instanceof UnhandledAlertException && (
e.getMessage().contains("Script Tag Failure - no status available") || // alert when navigating away quickly
e.getMessage().contains("Service_Proxy") // Alert from various GWT services (e.g. "from StudyDefinitionService_Proxy.getBlank")
));
}

private void testInjection(URL start)
{
String base = stripQueryParams(stripHash(start.toString()));
Expand Down Expand Up @@ -1409,16 +1392,11 @@ private void testInjection(URL start)
}
catch (Exception ex)
{
if (isRealFailure(ex))
{
throw new AssertionError("Non-injection error while attempting script injection on " + actionId + "\n" +
"param: " + paramMalicious + "\n" +
"URL: " + urlMalicious, ex);
}
throw new AssertionError("Non-injection error while attempting script injection on " + actionId + "\n" +
"param: " + paramMalicious + "\n" +
"URL: " + urlMalicious, ex);
}
}
// TODO this blows up jquery document completed handling, which causes pageload to not fire and then timeout
/// tryInject(_test, urlTester, base + "?" + query + "#" + injectString);
}

static Random random = new Random();
Expand Down