Repository: tapestry-5 Updated Branches: refs/heads/master 9c5e8abc4 -> adf455bd9
improve wait for page load Project: http://git-wip-us.apache.org/repos/asf/tapestry-5/repo Commit: http://git-wip-us.apache.org/repos/asf/tapestry-5/commit/adf455bd Tree: http://git-wip-us.apache.org/repos/asf/tapestry-5/tree/adf455bd Diff: http://git-wip-us.apache.org/repos/asf/tapestry-5/diff/adf455bd Branch: refs/heads/master Commit: adf455bd9d3bd49a41472e891213d640e159742a Parents: 9c5e8ab Author: Jochen Kemnade <[email protected]> Authored: Fri Nov 3 11:53:09 2017 +0100 Committer: Jochen Kemnade <[email protected]> Committed: Fri Nov 3 11:53:09 2017 +0100 ---------------------------------------------------------------------- .../apache/tapestry5/test/SeleniumTestCase.java | 18 ++++++++++++------ 1 file changed, 12 insertions(+), 6 deletions(-) ---------------------------------------------------------------------- http://git-wip-us.apache.org/repos/asf/tapestry-5/blob/adf455bd/tapestry-test/src/main/java/org/apache/tapestry5/test/SeleniumTestCase.java ---------------------------------------------------------------------- diff --git a/tapestry-test/src/main/java/org/apache/tapestry5/test/SeleniumTestCase.java b/tapestry-test/src/main/java/org/apache/tapestry5/test/SeleniumTestCase.java index 4a64591..a1fba91 100644 --- a/tapestry-test/src/main/java/org/apache/tapestry5/test/SeleniumTestCase.java +++ b/tapestry-test/src/main/java/org/apache/tapestry5/test/SeleniumTestCase.java @@ -19,6 +19,7 @@ import com.thoughtworks.selenium.webdriven.WebDriverCommandProcessor; import org.openqa.selenium.By; import org.openqa.selenium.JavascriptExecutor; +import org.openqa.selenium.NoSuchElementException; import org.openqa.selenium.WebDriver; import org.openqa.selenium.WebElement; import org.openqa.selenium.firefox.FirefoxDriver; @@ -1377,15 +1378,20 @@ public abstract class SeleniumTestCase extends Assert implements Selenium // In a limited number of cases, a "page" is an container error page or raw HTML content // that does not include the body element and data-page-initialized element. In those cases, // there will never be page initialization in the Tapestry sense and we return immediately. - - if (!isElementPresent("css=body[data-page-initialized]")) + try { - return; - } - + WebElement body = webDriver.findElement(By.cssSelector("body")); - waitForCondition(ExpectedConditions.attributeToBe(By.cssSelector("body"), "data-page-initialized", "true"), 30); + if (body.getAttribute("data-page-initialized") == null) + { + return; + } + waitForCondition(ExpectedConditions.attributeToBe(body, "data-page-initialized", "true"), 30); + } catch (NoSuchElementException e) + { + // no body element found, there's nothing to wait for + } } @Override
