Fix some more test-suite problems related to using jQuery
Project: http://git-wip-us.apache.org/repos/asf/tapestry-5/repo Commit: http://git-wip-us.apache.org/repos/asf/tapestry-5/commit/09bd34c8 Tree: http://git-wip-us.apache.org/repos/asf/tapestry-5/tree/09bd34c8 Diff: http://git-wip-us.apache.org/repos/asf/tapestry-5/diff/09bd34c8 Branch: refs/heads/master Commit: 09bd34c8bd1e735e340bdbac276d2b7810492cb6 Parents: f270cbc Author: Howard M. Lewis Ship <[email protected]> Authored: Mon Nov 25 12:11:08 2013 -0800 Committer: Howard M. Lewis Ship <[email protected]> Committed: Mon Nov 25 12:11:08 2013 -0800 ---------------------------------------------------------------------- .../tapestry5/integration/app1/FormTests.java | 19 +++++++++++++------ .../apache/tapestry5/test/SeleniumTestCase.java | 6 +++--- 2 files changed, 16 insertions(+), 9 deletions(-) ---------------------------------------------------------------------- http://git-wip-us.apache.org/repos/asf/tapestry-5/blob/09bd34c8/tapestry-core/src/test/java/org/apache/tapestry5/integration/app1/FormTests.java ---------------------------------------------------------------------- diff --git a/tapestry-core/src/test/java/org/apache/tapestry5/integration/app1/FormTests.java b/tapestry-core/src/test/java/org/apache/tapestry5/integration/app1/FormTests.java index 1928318..5a7732e 100644 --- a/tapestry-core/src/test/java/org/apache/tapestry5/integration/app1/FormTests.java +++ b/tapestry-core/src/test/java/org/apache/tapestry5/integration/app1/FormTests.java @@ -241,16 +241,19 @@ public class FormTests extends App1TestCase //move to the next month. click("css=button.nextButton"); + //first, make sure that NOTHING shows as selected! The selected date is still 5/28/46 - String selectedGoneCondition = "window.$$(\"td.selected\").size() == 0"; - waitForCondition(selectedGoneCondition, PAGE_LOAD_TIMEOUT); + + waitForSelectedToBeRemoved(); + //make sure it's still selected if we navigate back... click("css=button.previousButton"); waitForCSSSelectedElementToAppear("td.selected"); click("css=button.nextButton"); - waitForCondition(selectedGoneCondition, PAGE_LOAD_TIMEOUT); + + waitForSelectedToBeRemoved(); click("xpath=//td[text()='28']"); String pickerGoneSelector = "css=div.datePicker"; @@ -280,7 +283,8 @@ public class FormTests extends App1TestCase waitForCSSSelectedElementToAppear("div.datePicker"); click("css=button.nextButton"); - waitForCondition(selectedGoneCondition, PAGE_LOAD_TIMEOUT); + + waitForSelectedToBeRemoved(); click("css=div.datePicker .footerTable button"); waitForCSSSelectedElementToAppear("td.selected"); @@ -315,6 +319,11 @@ public class FormTests extends App1TestCase assertFieldValue("asteroidImpact", ""); } + private void waitForSelectedToBeRemoved() + { + waitForCondition("selenium.browserbot.getCurrentWindow().testSupport.findCSSMatchCount('td.selected') == 0", PAGE_LOAD_TIMEOUT); + } + // TAP4-1408 @Test public void datefield_clickoutside_closes() @@ -806,8 +815,6 @@ public class FormTests extends App1TestCase { openLinks("LinkSubmit Demo"); - waitForElementToAppear("fred"); - click("//a[@id='fred']"); assertTextPresent("You must provide a value for Name."); http://git-wip-us.apache.org/repos/asf/tapestry-5/blob/09bd34c8/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 db14829..1aee01a 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 @@ -1470,7 +1470,7 @@ public abstract class SeleniumTestCase extends Assert implements Selenium */ protected void waitForCSSSelectedElementToAppear(String cssSelector) { - String condition = String.format("window.testSupport.findCSSMatchCount(\"%s\") > 0", cssSelector); + String condition = String.format("selenium.browserbot.getCurrentWindow().testSupport.findCSSMatchCount(\"%s\") > 0", cssSelector); waitForCondition(condition, PAGE_LOAD_TIMEOUT); } @@ -1486,7 +1486,7 @@ public abstract class SeleniumTestCase extends Assert implements Selenium protected final void waitForElementToAppear(String elementId) { - String condition = String.format("window.getElementById(\"%s\")", elementId); + String condition = String.format("selenium.browserbot.getCurrentWindow().document.getElementById(\"%s\")", elementId); waitForCondition(condition, PAGE_LOAD_TIMEOUT); } @@ -1504,7 +1504,7 @@ public abstract class SeleniumTestCase extends Assert implements Selenium */ protected final void waitForElementToDisappear(String elementId) { - String condition = String.format("window.testSupport.doesNotExist(\"%s\")", elementId); + String condition = String.format("selenium.browserbot.getCurrentWindow().testSupport.doesNotExist(\"%s\")", elementId); waitForCondition(condition, PAGE_LOAD_TIMEOUT); }
