From 48e94c57b5da183b539e64067f14acd00351feb6 Mon Sep 17 00:00:00 2001 From: Basil Crow Date: Sun, 23 Jun 2019 09:23:46 -0700 Subject: [PATCH] Use WebClientUtil.waitForJSExec to wait for JavaScript (#43) --- .../TextFinderPublisherFreestyleTest.java | 16 ++-------------- 1 file changed, 2 insertions(+), 14 deletions(-) diff --git a/src/test/java/hudson/plugins/textfinder/TextFinderPublisherFreestyleTest.java b/src/test/java/hudson/plugins/textfinder/TextFinderPublisherFreestyleTest.java index 503cc8d..6199370 100644 --- a/src/test/java/hudson/plugins/textfinder/TextFinderPublisherFreestyleTest.java +++ b/src/test/java/hudson/plugins/textfinder/TextFinderPublisherFreestyleTest.java @@ -3,6 +3,7 @@ import static org.junit.Assert.assertEquals; import static org.junit.Assert.assertTrue; +import com.gargoylesoftware.htmlunit.WebClientUtil; import com.gargoylesoftware.htmlunit.html.HtmlForm; import com.gargoylesoftware.htmlunit.html.HtmlPage; import hudson.Functions; @@ -14,8 +15,6 @@ import hudson.tasks.Shell; import java.io.File; import java.io.IOException; -import java.util.HashSet; -import java.util.Set; import org.junit.Rule; import org.junit.Test; import org.jvnet.hudson.test.JenkinsRule; @@ -144,18 +143,7 @@ public void createTextFinderViaWebClient() throws Exception { page.getAnchorByText("Text Finder").click(); // Wait for the YUI JavaScript to load. - Set requiredInputs = new HashSet<>(); - requiredInputs.add("_.fileSet"); - requiredInputs.add("_.regexp"); - requiredInputs.add("_.succeedIfFound"); - requiredInputs.add("_.unstableIfFound"); - requiredInputs.add("_.notBuiltIfFound"); - requiredInputs.add("_.alsoCheckConsoleOutput"); - for (String requiredInput : requiredInputs) { - while (config.getInputsByName(requiredInput).isEmpty()) { - Thread.sleep(100); - } - } + WebClientUtil.waitForJSExec(page.getWebClient()); // Configure the Text Finder. config.getInputByName("_.fileSet").setValueAttribute("file1");