diff --git a/pom.xml b/pom.xml index d788cdfa..7183e469 100644 --- a/pom.xml +++ b/pom.xml @@ -17,17 +17,17 @@ Apache Software License 2.0 - http://www.apache.org/licenses/LICENSE-2.0.txt + https://www.apache.org/licenses/LICENSE-2.0.txt repo GOT5 https://github.com/got5 - + Github - http://github.com/got5 + https://github.com/got5 scm:git:git@github.com:got5/tapestry5-jquery.git @@ -81,7 +81,7 @@ org.seleniumhq.selenium - selenium-java + selenium-support ${selenium-version} test @@ -97,9 +97,19 @@ org.seleniumhq.selenium - selenium-server + selenium-leg-rc ${selenium-version} test + + + jetty-websocket + org.eclipse.jetty + + + javax.servlet-api + javax.servlet + + ch.qos.logback @@ -147,8 +157,8 @@ maven-compiler-plugin 2.3.2 - 1.5 - 1.5 + 8 + 8 true @@ -274,7 +284,7 @@ none:none org.testng:testng - target/test-classes/testng.xml + target/test-classes/testng.xml **/*.groovy @@ -285,8 +295,8 @@ - - + + org.apache.maven.plugins maven-assembly-plugin @@ -344,7 +354,7 @@ org.codehaus.mojo cobertura-maven-plugin 2.5 - + @@ -356,7 +366,7 @@ central Maven Repository default - http://central.maven.org/maven2/ + https://repo1.maven.org/maven2/ false @@ -365,12 +375,12 @@ maven - http://central.maven.org/maven2/ + https://repo1.maven.org/maven2/ spring-maven-release Spring Maven Release Repository - http://maven.springframework.org/release + https://maven.springframework.org/release @@ -432,8 +442,8 @@ 0.6-groovy-1.8 - 5.4.1 - 2.35.0 + 5.6.3 + 3.12.0 *googlechrome src/main/java diff --git a/src/main/java/org/got5/tapestry5/jquery/mixins/CustomDatepicker.java b/src/main/java/org/got5/tapestry5/jquery/mixins/CustomDatepicker.java index 0d359442..51823021 100644 --- a/src/main/java/org/got5/tapestry5/jquery/mixins/CustomDatepicker.java +++ b/src/main/java/org/got5/tapestry5/jquery/mixins/CustomDatepicker.java @@ -64,7 +64,7 @@ public class CustomDatepicker { @Inject @Symbol(JQuerySymbolConstants.SUPPRESS_PROTOTYPE) - private Boolean supressPrototype; + private Boolean suppressPrototype; @Inject private ThreadLocale locale; @@ -85,7 +85,7 @@ public class CustomDatepicker { * change the JSON option of the jQuery datepicker widget */ void afterRender() { - if (supressPrototype) { + if (suppressPrototype) { /* * If the selector parameter is not bound, we will use the clientId * of the component using the mixin @@ -101,7 +101,7 @@ void afterRender() { JSONObject temp = widgetParams.paramsForWidget(this.getClass().getSimpleName().toLowerCase()); if(temp != null){ - defaultParamsObject = temp; + defaultParamsObject = temp.copy(); } defaultParamsObject.put("dateFormat", toJQueryUIDateFormat()); diff --git a/src/main/java/org/got5/tapestry5/jquery/services/WidgetParams.java b/src/main/java/org/got5/tapestry5/jquery/services/WidgetParams.java index 2e0971d7..cba4d3c2 100644 --- a/src/main/java/org/got5/tapestry5/jquery/services/WidgetParams.java +++ b/src/main/java/org/got5/tapestry5/jquery/services/WidgetParams.java @@ -13,6 +13,6 @@ @UsesMappedConfiguration(value = JSONObject.class) public interface WidgetParams { - public abstract JSONObject paramsForWidget(String widget); + JSONObject paramsForWidget(String widget); } \ No newline at end of file diff --git a/src/main/resources/META-INF/modules/tjq/PageScroll.js b/src/main/resources/META-INF/modules/tjq/PageScroll.js index d1073fcb..db6edbe3 100644 --- a/src/main/resources/META-INF/modules/tjq/PageScroll.js +++ b/src/main/resources/META-INF/modules/tjq/PageScroll.js @@ -27,7 +27,7 @@ define([ "t5/core/dom", "t5/core/zone", "t5/core/events", "tjq/vendor/components this.disable = true; scroller.addClass("scrollExtend-loading"); - if (activeZone.length != 0) { + if (activeZone.length !== 0) { this.disable = true; activeZone.trigger(events.zone.refresh, { diff --git a/src/test/java/org/got5/tapestry5/jquery/AccordionTest.java b/src/test/java/org/got5/tapestry5/jquery/AccordionTest.java index e18e0b80..aaa00aa2 100644 --- a/src/test/java/org/got5/tapestry5/jquery/AccordionTest.java +++ b/src/test/java/org/got5/tapestry5/jquery/AccordionTest.java @@ -1,11 +1,11 @@ package org.got5.tapestry5.jquery; -import org.apache.tapestry5.test.SeleniumTestCase; +import org.got5.tapestry5.jquery.test.SeleniumTestCase2; import org.testng.annotations.Test; import com.thoughtworks.selenium.Wait; -public class AccordionTest extends SeleniumTestCase{ +public class AccordionTest extends SeleniumTestCase2{ @Test public void testAccordion() diff --git a/src/test/java/org/got5/tapestry5/jquery/AjaxFormLoopTest.java b/src/test/java/org/got5/tapestry5/jquery/AjaxFormLoopTest.java index 94623f22..e2cb366d 100644 --- a/src/test/java/org/got5/tapestry5/jquery/AjaxFormLoopTest.java +++ b/src/test/java/org/got5/tapestry5/jquery/AjaxFormLoopTest.java @@ -1,11 +1,11 @@ package org.got5.tapestry5.jquery; -import org.apache.tapestry5.test.SeleniumTestCase; +import org.got5.tapestry5.jquery.test.SeleniumTestCase2; import org.testng.annotations.Test; import com.thoughtworks.selenium.Wait; -public class AjaxFormLoopTest extends SeleniumTestCase{ +public class AjaxFormLoopTest extends SeleniumTestCase2{ @Test public void testAjaxFormLoop(){ diff --git a/src/test/java/org/got5/tapestry5/jquery/AutocompleteTest.java b/src/test/java/org/got5/tapestry5/jquery/AutocompleteTest.java index ec11dbda..5427992c 100644 --- a/src/test/java/org/got5/tapestry5/jquery/AutocompleteTest.java +++ b/src/test/java/org/got5/tapestry5/jquery/AutocompleteTest.java @@ -1,11 +1,11 @@ package org.got5.tapestry5.jquery; -import org.apache.tapestry5.test.SeleniumTestCase; -import org.testng.annotations.Test; - import com.thoughtworks.selenium.Wait; +import org.got5.tapestry5.jquery.test.SeleniumTestCase2; +import org.openqa.selenium.interactions.Actions; +import org.testng.annotations.Test; -public class AutocompleteTest extends SeleniumTestCase{ +public class AutocompleteTest extends SeleniumTestCase2{ @Test public void testAutoComplete() @@ -13,11 +13,9 @@ public void testAutoComplete() open("/ext/jqueryautocomplete"); waitForPageToLoad(); - focus("identifier=foo"); - type("identifier=foo", "abcdeff"); - keyDown("identifier=foo", "e"); - keyUp("identifier=foo", "e"); - fireEvent("identifier=foo", "keydown"); + focus("id=foo"); + type("id=foo", "abcdeff"); + new Actions(webDriver).sendKeys("e").perform(); new Wait() { diff --git a/src/test/java/org/got5/tapestry5/jquery/BindTest.java b/src/test/java/org/got5/tapestry5/jquery/BindTest.java index d7d91b91..8b2b4d8b 100644 --- a/src/test/java/org/got5/tapestry5/jquery/BindTest.java +++ b/src/test/java/org/got5/tapestry5/jquery/BindTest.java @@ -1,11 +1,11 @@ package org.got5.tapestry5.jquery; -import org.apache.tapestry5.test.SeleniumTestCase; +import org.got5.tapestry5.jquery.test.SeleniumTestCase2; import org.testng.annotations.Test; import com.thoughtworks.selenium.Wait; -public class BindTest extends SeleniumTestCase{ +public class BindTest extends SeleniumTestCase2{ @Test public void testBind(){ @@ -31,7 +31,7 @@ public boolean until() } }.wait("element not found", JQueryTestConstants.TIMEOUT); - assertEquals(getText("identifier=clickZone"), "click OK"); + assertEquals(getText("id=clickZone"), "click OK"); } } diff --git a/src/test/java/org/got5/tapestry5/jquery/ButtonTest.java b/src/test/java/org/got5/tapestry5/jquery/ButtonTest.java index 9ee8b222..fd5b8274 100644 --- a/src/test/java/org/got5/tapestry5/jquery/ButtonTest.java +++ b/src/test/java/org/got5/tapestry5/jquery/ButtonTest.java @@ -1,11 +1,11 @@ package org.got5.tapestry5.jquery; -import org.apache.tapestry5.test.SeleniumTestCase; +import org.got5.tapestry5.jquery.test.SeleniumTestCase2; import org.testng.annotations.Test; import com.thoughtworks.selenium.Wait; -public class ButtonTest extends SeleniumTestCase{ +public class ButtonTest extends SeleniumTestCase2{ @Test public void testButtonMixin(){ diff --git a/src/test/java/org/got5/tapestry5/jquery/CalendarTest.java b/src/test/java/org/got5/tapestry5/jquery/CalendarTest.java index 853f37b1..99d4c1aa 100644 --- a/src/test/java/org/got5/tapestry5/jquery/CalendarTest.java +++ b/src/test/java/org/got5/tapestry5/jquery/CalendarTest.java @@ -1,107 +1,98 @@ package org.got5.tapestry5.jquery; import com.thoughtworks.selenium.Wait; -import org.apache.tapestry5.test.SeleniumTestCase; +import org.got5.tapestry5.jquery.test.SeleniumTestCase2; +import org.openqa.selenium.By; +import org.openqa.selenium.WebElement; +import org.openqa.selenium.support.ui.ExpectedConditions; import org.testng.annotations.Test; -public class CalendarTest extends SeleniumTestCase{ - - @Test - public void testCalendar() - { +import static org.openqa.selenium.support.ui.ExpectedConditions.presenceOfElementLocated; +import static org.openqa.selenium.support.ui.ExpectedConditions.stalenessOf; + +public class CalendarTest extends SeleniumTestCase2 { + + @Test + public void testCalendar() { open("/calendar"); waitForPageToLoad(); - new Wait() - { + new Wait() { @Override - public boolean until() - { + public boolean until() { return isElementPresent("//button[@class='ui-datepicker-trigger']"); } }.wait("element not found!", JQueryTestConstants.TIMEOUT); - + click("//button[@class='ui-datepicker-trigger']"); - new Wait() - { + new Wait() { @Override - public boolean until() - { - return isElementPresent("identifier=ui-datepicker-div") && isVisible("identifier=ui-datepicker-div"); + public boolean until() { + return isElementPresent("id=ui-datepicker-div") && isVisible("id=ui-datepicker-div"); } }.wait("element not found!", JQueryTestConstants.TIMEOUT); - assertEquals(true, isVisible("identifier=ui-datepicker-div")); + assertEquals(true, isVisible("id=ui-datepicker-div")); + } + + @Test + public void testCalendarInZone() { + + testLocalInZone("en", "Next"); + + testLocalInZone("fr", "Suivant"); } - - @Test - public void testCalendarInZone(){ - - testLocalInZone("en", "Next"); - - testLocalInZone("fr", "Suivant"); - } - - private void testLocalInZone(String locale, final String text){ - + + private void testLocalInZone(String locale, final String text) { + open("/" + locale + "/calendarinzone"); - - new Wait() - { + + new Wait() { @Override - public boolean until() - { + public boolean until() { return isElementPresent("//button[@class='ui-datepicker-trigger']"); } }.wait("element not found!", JQueryTestConstants.TIMEOUT); - - click("//section/a[@data-update-zone='zone']"); - - new Wait() - { - @Override - public boolean until() - { - return isElementPresent("//button[@class='ui-datepicker-trigger']"); - } - }.wait("button[@class='ui-datepicker-trigger'] not found!", JQueryTestConstants.TIMEOUT); - click("//button[@class='ui-datepicker-trigger']"); - - new Wait() - { + By datepickerTriggerLocator = convertLocator("//button[@class='ui-datepicker-trigger']"); + WebElement datepickerTrigger = webDriver.findElement(datepickerTriggerLocator); + + click("//section/a[@data-update-zone='zone']"); + + waitForCondition( + ExpectedConditions.and( + stalenessOf(datepickerTrigger), + presenceOfElementLocated(datepickerTriggerLocator)), + "button[@class='ui-datepicker-trigger'] not found!"); + + click(datepickerTriggerLocator); + + new Wait() { @Override - public boolean until() - { + public boolean until() { return getAttribute("//a[contains(@class,'ui-datepicker-next')]@title").equalsIgnoreCase(text); - } }.wait(text + " element not visible! " + getAttribute("//a[contains(@class,'ui-datepicker-next')]@title"), JQueryTestConstants.TIMEOUT); - - } + } @Test public void testCalendarDisabled() { open("/calendardisabled"); - waitForPageToLoad(); - assertEquals(false, isEditable("identifier=datefield")); + assertFalse(isEditable("id=datefield")); - new Wait() - { + new Wait() { @Override - public boolean until() - { + public boolean until() { return isElementPresent("//button[@class='ui-datepicker-trigger']"); } }.wait("element not found!", JQueryTestConstants.TIMEOUT); - - click("//button[@class='ui-datepicker-trigger']"); - assertEquals(false, isVisible("identifier=ui-datepicker-div")); + click("//button[@class='ui-datepicker-trigger']"); + assertFalse(isVisible("id=ui-datepicker-div")); } } diff --git a/src/test/java/org/got5/tapestry5/jquery/CarouselTest.java b/src/test/java/org/got5/tapestry5/jquery/CarouselTest.java index 8dc9723d..4c4db8be 100644 --- a/src/test/java/org/got5/tapestry5/jquery/CarouselTest.java +++ b/src/test/java/org/got5/tapestry5/jquery/CarouselTest.java @@ -16,13 +16,13 @@ package org.got5.tapestry5.jquery; -import org.apache.tapestry5.test.SeleniumTestCase; +import org.got5.tapestry5.jquery.test.SeleniumTestCase2; import org.testng.annotations.BeforeMethod; import org.testng.annotations.Test; import com.thoughtworks.selenium.Wait; -public class CarouselTest extends SeleniumTestCase { +public class CarouselTest extends SeleniumTestCase2 { @BeforeMethod public void adjustSpeed() { @@ -33,17 +33,17 @@ public void adjustSpeed() { @Test public void testCarousel() { open("/carouselpage"); - waitForPageToLoad(); + //Content test assertEquals(getText("css=#zoneContainer span"), "Click on the big white flower of the complex carousel:", "The page does not seem to be fully loaded"); //test of an eventlink inside a carousel - assertTrue("".equals(getText("id=flowerZone")),"The zone is not empty before the ajax call"); - click("//*[@id='carouselitem_0']/img"); + assertEquals(getText("id=flowerZone"), "", "The zone is not empty before the ajax call"); + clickAndWait("//*[@id='carouselitem_0']/img"); assertEquals(getText("id=flowerZone"),"You just clicked on the big white flower !", "The eventlink did not work, the zone did not load correctly"); //Carousel control test final int initPosition = (Integer) getElementPositionLeft("css=.jcarousel-list"); - click("css=.jcarousel-next"); + clickAndWait("css=.jcarousel-next"); new Wait() { @Override @@ -53,7 +53,5 @@ public boolean until() return Math.abs(initPosition - newPosition)==255; } }.wait("The carousel did not slide correctly", JQueryTestConstants.TIMEOUT); - - } } diff --git a/src/test/java/org/got5/tapestry5/jquery/CheckboxTest.java b/src/test/java/org/got5/tapestry5/jquery/CheckboxTest.java index 21dba01b..4a1831d5 100644 --- a/src/test/java/org/got5/tapestry5/jquery/CheckboxTest.java +++ b/src/test/java/org/got5/tapestry5/jquery/CheckboxTest.java @@ -1,11 +1,11 @@ package org.got5.tapestry5.jquery; -import org.apache.tapestry5.test.SeleniumTestCase; +import org.got5.tapestry5.jquery.test.SeleniumTestCase2; import org.testng.annotations.Test; import com.thoughtworks.selenium.Wait; -public class CheckboxTest extends SeleniumTestCase{ +public class CheckboxTest extends SeleniumTestCase2{ @Test public void testCheckboxComponent(){ diff --git a/src/test/java/org/got5/tapestry5/jquery/ConfirmTest.java b/src/test/java/org/got5/tapestry5/jquery/ConfirmTest.java index 41da5be9..80537c0d 100644 --- a/src/test/java/org/got5/tapestry5/jquery/ConfirmTest.java +++ b/src/test/java/org/got5/tapestry5/jquery/ConfirmTest.java @@ -16,69 +16,63 @@ package org.got5.tapestry5.jquery; -import org.apache.tapestry5.test.SeleniumTestCase; +import org.got5.tapestry5.jquery.test.SeleniumTestCase2; +import org.openqa.selenium.WebElement; +import org.openqa.selenium.support.ui.ExpectedCondition; import org.testng.annotations.Test; -import com.thoughtworks.selenium.Wait; +public class ConfirmTest extends SeleniumTestCase2 +{ + private final String confirmLocator = "//div[@id='dialogConfirmationJQuery']"; -public class ConfirmTest extends SeleniumTestCase { - - private final String confirmLocator = "//div[@id='dialogConfirmationJQuery']"; - - private final String confirmOkLocator = "//div[@class='ui-dialog-buttonset']/button[1]"; - - @Test + private final String confirmOkLocator = "//div[@class='ui-dialog-buttonset']/button[1]"; + + @Test public void testDialog() { open("/jqueryconfirm"); - + //PageLink Confirmation test. checkDialogStateAfterClick("//a[@id='pageLinkTest']"); - + //Did we quit the JQueryConfirm Page? final String baseUrl = getBaseURL(); - assertTrue(baseUrl.indexOf("/jqueryconfirm") == -1); - - //open("/jqueryconfirm"); - + assertEquals(-1, baseUrl.indexOf("/jqueryconfirm")); + + open("/jqueryconfirm"); + //Zone update confirmation - //checkDialogStateAfterClick("//a[@id='clicker']"); - + checkDialogStateAfterClick("//a[@id='clicker']"); + //Form submit confirmation - //checkDialogStateAfterClick("//input[@id='btnValid']"); + checkDialogStateAfterClick("//input[@id='btnValid']"); } - - private void checkDialogStateAfterClick(final String triggerLocator) + + private void checkDialogStateAfterClick(final String triggerLocator) { click(triggerLocator); - + //Checks if the confirm popup is displayed. - new Wait() - { - @Override - public boolean until() - { - return (isVisible(confirmLocator)); - } - }.wait("Confirm popup should be visible after clicking on : " + triggerLocator, JQueryTestConstants.TIMEOUT); - + waitForCondition( + (ExpectedCondition) webDriver -> + // A page may contain more than one rendered confirmation popup, + // but they're likely hidden waiting for their trigger + findFirstVisible(webDriver, convertLocator(confirmLocator)), + "Confirm popup should be visible after clicking on : " + triggerLocator); + //Confirm dialog popup closed by pressing Enter key. checkDialogStateAfterClickOK(); } - - private void checkDialogStateAfterClickOK() + + private void checkDialogStateAfterClickOK() { - //Press OK button. - click(confirmOkLocator); - + //Press OK button. + clickAndWait(findFirstVisible(webDriver, convertLocator(confirmOkLocator))); + //Checks if the popup has been removed. - new Wait() - { - @Override - public boolean until() - { - return (!isVisible(confirmLocator)); - } - }.wait("Confirm popup should be removed after clicking on OK button.", JQueryTestConstants.TIMEOUT); + assertNotPresent( + convertLocator(confirmLocator), + WebElement::isDisplayed, + "Confirm popup should be removed after clicking on OK button."); } } diff --git a/src/test/java/org/got5/tapestry5/jquery/ContextMenuTest.java b/src/test/java/org/got5/tapestry5/jquery/ContextMenuTest.java index 5f6f895f..ae4085db 100644 --- a/src/test/java/org/got5/tapestry5/jquery/ContextMenuTest.java +++ b/src/test/java/org/got5/tapestry5/jquery/ContextMenuTest.java @@ -1,9 +1,11 @@ package org.got5.tapestry5.jquery; -import org.apache.tapestry5.test.SeleniumTestCase; +import org.got5.tapestry5.jquery.test.SeleniumTestCase2; +import org.openqa.selenium.WebElement; +import org.openqa.selenium.interactions.Actions; import org.testng.annotations.Test; -public class ContextMenuTest extends SeleniumTestCase { +public class ContextMenuTest extends SeleniumTestCase2 { @Test public void testContextMenu() { @@ -11,8 +13,9 @@ public void testContextMenu() { open("/jquerycontextmenu"); //We check if the context menu is displayed on right click... - mouseDownRight("//a[@class='linkContextMenu']"); - mouseUpRight("//a[@class='linkContextMenu']"); + WebElement element = webDriver.findElement(convertLocator("//a[@class='linkContextMenu']")); + new Actions(webDriver).contextClick(element); + assertTrue(isElementPresent("//ul[@class='context-menu-list context-menu-root']")); //... And if the menu entries are rendered. diff --git a/src/test/java/org/got5/tapestry5/jquery/CustomDatepickerTest.java b/src/test/java/org/got5/tapestry5/jquery/CustomDatepickerTest.java index 3442488f..392acb68 100644 --- a/src/test/java/org/got5/tapestry5/jquery/CustomDatepickerTest.java +++ b/src/test/java/org/got5/tapestry5/jquery/CustomDatepickerTest.java @@ -16,12 +16,12 @@ package org.got5.tapestry5.jquery; -import org.apache.tapestry5.test.SeleniumTestCase; +import org.got5.tapestry5.jquery.test.SeleniumTestCase2; import org.testng.annotations.Test; import com.thoughtworks.selenium.Wait; -public class CustomDatepickerTest extends SeleniumTestCase { +public class CustomDatepickerTest extends SeleniumTestCase2 { @Test public void testCustomDatepicker() { diff --git a/src/test/java/org/got5/tapestry5/jquery/DataTableAjaxTest.java b/src/test/java/org/got5/tapestry5/jquery/DataTableAjaxTest.java index 2d4d3ffa..b3bd7fd5 100644 --- a/src/test/java/org/got5/tapestry5/jquery/DataTableAjaxTest.java +++ b/src/test/java/org/got5/tapestry5/jquery/DataTableAjaxTest.java @@ -1,11 +1,11 @@ package org.got5.tapestry5.jquery; -import org.apache.tapestry5.test.SeleniumTestCase; +import org.got5.tapestry5.jquery.test.SeleniumTestCase2; import org.testng.annotations.Test; import com.thoughtworks.selenium.Wait; -public class DataTableAjaxTest extends SeleniumTestCase{ +public class DataTableAjaxTest extends SeleniumTestCase2{ @Test public void testHeaderOverride(){ diff --git a/src/test/java/org/got5/tapestry5/jquery/DataTableTest.java b/src/test/java/org/got5/tapestry5/jquery/DataTableTest.java index 8f74678a..fd39811c 100644 --- a/src/test/java/org/got5/tapestry5/jquery/DataTableTest.java +++ b/src/test/java/org/got5/tapestry5/jquery/DataTableTest.java @@ -1,11 +1,11 @@ package org.got5.tapestry5.jquery; -import org.apache.tapestry5.test.SeleniumTestCase; +import org.got5.tapestry5.jquery.test.SeleniumTestCase2; import org.testng.annotations.Test; import com.thoughtworks.selenium.Wait; -public class DataTableTest extends SeleniumTestCase{ +public class DataTableTest extends SeleniumTestCase2{ @Test public void testHeaderOverride(){ diff --git a/src/test/java/org/got5/tapestry5/jquery/DialogTest.java b/src/test/java/org/got5/tapestry5/jquery/DialogTest.java index 7b50ea31..cbf57d49 100644 --- a/src/test/java/org/got5/tapestry5/jquery/DialogTest.java +++ b/src/test/java/org/got5/tapestry5/jquery/DialogTest.java @@ -16,18 +16,18 @@ package org.got5.tapestry5.jquery; -import org.apache.tapestry5.test.SeleniumTestCase; +import org.got5.tapestry5.jquery.test.SeleniumTestCase2; import org.testng.annotations.Test; import com.thoughtworks.selenium.Wait; -public class DialogTest extends SeleniumTestCase { +public class DialogTest extends SeleniumTestCase2 { - String dialogLink = "identifier=dialoglink"; - String dialogAjaxLink = "identifier=dialogajaxlink"; - final String dialog = "identifier=myDialog"; + String dialogLink = "id=dialoglink"; + String dialogAjaxLink = "id=dialogajaxlink"; + final String dialog = "id=myDialog"; String closeDialog = "css=span[class~=\"ui-icon-closethick\"]"; - String zone = "identifier=myzone"; + String zone = "id=myzone"; @Test public void testDialog() diff --git a/src/test/java/org/got5/tapestry5/jquery/DraggableTest.java b/src/test/java/org/got5/tapestry5/jquery/DraggableTest.java index 92eb2c2c..5e8a1816 100644 --- a/src/test/java/org/got5/tapestry5/jquery/DraggableTest.java +++ b/src/test/java/org/got5/tapestry5/jquery/DraggableTest.java @@ -1,12 +1,12 @@ package org.got5.tapestry5.jquery; -import org.apache.tapestry5.test.SeleniumTestCase; +import org.got5.tapestry5.jquery.test.SeleniumTestCase2; import org.testng.annotations.Test; import com.thoughtworks.selenium.Wait; -public class DraggableTest extends SeleniumTestCase { +public class DraggableTest extends SeleniumTestCase2 { @Test public void dragItem1() { diff --git a/src/test/java/org/got5/tapestry5/jquery/FlexSlider.java b/src/test/java/org/got5/tapestry5/jquery/FlexSlider.java index 27c9511e..c9fcf330 100644 --- a/src/test/java/org/got5/tapestry5/jquery/FlexSlider.java +++ b/src/test/java/org/got5/tapestry5/jquery/FlexSlider.java @@ -1,11 +1,11 @@ package org.got5.tapestry5.jquery; -import org.apache.tapestry5.test.SeleniumTestCase; +import org.got5.tapestry5.jquery.test.SeleniumTestCase2; import org.testng.annotations.Test; import com.thoughtworks.selenium.Wait; -public class FlexSlider extends SeleniumTestCase { +public class FlexSlider extends SeleniumTestCase2 { @Test public void testNavList() { diff --git a/src/test/java/org/got5/tapestry5/jquery/FormTest.java b/src/test/java/org/got5/tapestry5/jquery/FormTest.java index dfdbb25e..74f30ae8 100644 --- a/src/test/java/org/got5/tapestry5/jquery/FormTest.java +++ b/src/test/java/org/got5/tapestry5/jquery/FormTest.java @@ -1,11 +1,11 @@ package org.got5.tapestry5.jquery; -import org.apache.tapestry5.test.SeleniumTestCase; +import org.got5.tapestry5.jquery.test.SeleniumTestCase2; import org.testng.annotations.Test; import com.thoughtworks.selenium.Wait; -public class FormTest extends SeleniumTestCase{ +public class FormTest extends SeleniumTestCase2{ @Test public void testAjaxFormLoop(){ diff --git a/src/test/java/org/got5/tapestry5/jquery/FormfragmentTest.java b/src/test/java/org/got5/tapestry5/jquery/FormfragmentTest.java index e8871de6..9f6a93b3 100644 --- a/src/test/java/org/got5/tapestry5/jquery/FormfragmentTest.java +++ b/src/test/java/org/got5/tapestry5/jquery/FormfragmentTest.java @@ -1,11 +1,11 @@ package org.got5.tapestry5.jquery; -import org.apache.tapestry5.test.SeleniumTestCase; +import org.got5.tapestry5.jquery.test.SeleniumTestCase2; import org.testng.annotations.Test; import com.thoughtworks.selenium.Wait; -public class FormfragmentTest extends SeleniumTestCase{ +public class FormfragmentTest extends SeleniumTestCase2{ @Test public void testFormFragment() @@ -13,7 +13,7 @@ public void testFormFragment() open("/formfragment"); waitForPageToLoad(); - String trigger = "identifier=separateShipTo"; + String trigger = "id=separateShipTo"; final String fragment = "//div[@id='seperateShippingAddress']"; assertFalse(isVisible(fragment), fragment + " should not be visible"); diff --git a/src/test/java/org/got5/tapestry5/jquery/GalleryTest.java b/src/test/java/org/got5/tapestry5/jquery/GalleryTest.java index a456da9a..b97940d0 100644 --- a/src/test/java/org/got5/tapestry5/jquery/GalleryTest.java +++ b/src/test/java/org/got5/tapestry5/jquery/GalleryTest.java @@ -1,12 +1,12 @@ package org.got5.tapestry5.jquery; -import org.apache.tapestry5.test.SeleniumTestCase; +import org.got5.tapestry5.jquery.test.SeleniumTestCase2; import org.testng.annotations.BeforeMethod; import org.testng.annotations.Test; import com.thoughtworks.selenium.Wait; -public class GalleryTest extends SeleniumTestCase { +public class GalleryTest extends SeleniumTestCase2 { @BeforeMethod public void adjustSpeed() { diff --git a/src/test/java/org/got5/tapestry5/jquery/InPlaceEditorTest.java b/src/test/java/org/got5/tapestry5/jquery/InPlaceEditorTest.java index 5924dda4..db94e3b5 100644 --- a/src/test/java/org/got5/tapestry5/jquery/InPlaceEditorTest.java +++ b/src/test/java/org/got5/tapestry5/jquery/InPlaceEditorTest.java @@ -1,11 +1,11 @@ package org.got5.tapestry5.jquery; -import org.apache.tapestry5.test.SeleniumTestCase; +import org.got5.tapestry5.jquery.test.SeleniumTestCase2; import org.testng.annotations.Test; import com.thoughtworks.selenium.Wait; -public class InPlaceEditorTest extends SeleniumTestCase{ +public class InPlaceEditorTest extends SeleniumTestCase2{ @Test public void testInPlaceEditor(){ diff --git a/src/test/java/org/got5/tapestry5/jquery/JGrowlTest.java b/src/test/java/org/got5/tapestry5/jquery/JGrowlTest.java index f63c456a..3fb19e14 100644 --- a/src/test/java/org/got5/tapestry5/jquery/JGrowlTest.java +++ b/src/test/java/org/got5/tapestry5/jquery/JGrowlTest.java @@ -1,11 +1,11 @@ package org.got5.tapestry5.jquery; -import org.apache.tapestry5.test.SeleniumTestCase; +import org.got5.tapestry5.jquery.test.SeleniumTestCase2; import org.testng.annotations.Test; import com.thoughtworks.selenium.Wait; -public class JGrowlTest extends SeleniumTestCase{ +public class JGrowlTest extends SeleniumTestCase2{ @Test public void testTransiant(){ diff --git a/src/test/java/org/got5/tapestry5/jquery/JScrollPaneTest.java b/src/test/java/org/got5/tapestry5/jquery/JScrollPaneTest.java index a8930595..717893a9 100644 --- a/src/test/java/org/got5/tapestry5/jquery/JScrollPaneTest.java +++ b/src/test/java/org/got5/tapestry5/jquery/JScrollPaneTest.java @@ -1,11 +1,11 @@ package org.got5.tapestry5.jquery; -import org.apache.tapestry5.test.SeleniumTestCase; +import org.got5.tapestry5.jquery.test.SeleniumTestCase2; import org.testng.annotations.Test; import com.thoughtworks.selenium.Wait; -public class JScrollPaneTest extends SeleniumTestCase { +public class JScrollPaneTest extends SeleniumTestCase2 { @Test public void testVerticalOnly() { diff --git a/src/test/java/org/got5/tapestry5/jquery/LinksubmitTest.java b/src/test/java/org/got5/tapestry5/jquery/LinksubmitTest.java index 9b0b672a..6f6a6627 100644 --- a/src/test/java/org/got5/tapestry5/jquery/LinksubmitTest.java +++ b/src/test/java/org/got5/tapestry5/jquery/LinksubmitTest.java @@ -1,10 +1,10 @@ package org.got5.tapestry5.jquery; -import org.apache.tapestry5.test.SeleniumTestCase; +import org.got5.tapestry5.jquery.test.SeleniumTestCase2; import org.openqa.selenium.Keys; import org.testng.annotations.Test; -public class LinksubmitTest extends SeleniumTestCase{ +public class LinksubmitTest extends SeleniumTestCase2{ public void testLinkSubmit() @@ -12,9 +12,9 @@ public void testLinkSubmit() open("/ext/jquerylinksubmit"); waitForPageToLoad(); - String field = "identifier=textfield"; - String link = "identifier=fred"; - String result = "identifier=result"; + String field = "id=textfield"; + String link = "id=fred"; + String result = "id=result"; type(field, "dummy"); focus(field); diff --git a/src/test/java/org/got5/tapestry5/jquery/MaskTest.java b/src/test/java/org/got5/tapestry5/jquery/MaskTest.java index 413f0197..071af332 100644 --- a/src/test/java/org/got5/tapestry5/jquery/MaskTest.java +++ b/src/test/java/org/got5/tapestry5/jquery/MaskTest.java @@ -1,9 +1,9 @@ package org.got5.tapestry5.jquery; -import org.apache.tapestry5.test.SeleniumTestCase; +import org.got5.tapestry5.jquery.test.SeleniumTestCase2; import org.testng.annotations.Test; -public class MaskTest extends SeleniumTestCase{ +public class MaskTest extends SeleniumTestCase2{ /** * Test Method for Mask mixin diff --git a/src/test/java/org/got5/tapestry5/jquery/PageScrollTest.java b/src/test/java/org/got5/tapestry5/jquery/PageScrollTest.java index e86d6629..aa5f471e 100644 --- a/src/test/java/org/got5/tapestry5/jquery/PageScrollTest.java +++ b/src/test/java/org/got5/tapestry5/jquery/PageScrollTest.java @@ -1,9 +1,9 @@ package org.got5.tapestry5.jquery; -import org.apache.tapestry5.test.SeleniumTestCase; +import org.got5.tapestry5.jquery.test.SeleniumTestCase2; import org.testng.annotations.Test; -public class PageScrollTest extends SeleniumTestCase { +public class PageScrollTest extends SeleniumTestCase2 { @Test public void page_scroll_works(){ diff --git a/src/test/java/org/got5/tapestry5/jquery/PaletteTest.java b/src/test/java/org/got5/tapestry5/jquery/PaletteTest.java index 1fc89090..2b97cea9 100644 --- a/src/test/java/org/got5/tapestry5/jquery/PaletteTest.java +++ b/src/test/java/org/got5/tapestry5/jquery/PaletteTest.java @@ -1,37 +1,48 @@ package org.got5.tapestry5.jquery; -import org.apache.tapestry5.test.SeleniumTestCase; +import com.sun.org.apache.xpath.internal.operations.Bool; +import org.checkerframework.checker.nullness.compatqual.NullableDecl; +import org.got5.tapestry5.jquery.test.SeleniumTestCase2; +import org.openqa.selenium.By; +import org.openqa.selenium.WebDriver; +import org.openqa.selenium.WebElement; +import org.openqa.selenium.interactions.Action; +import org.openqa.selenium.interactions.Actions; +import org.openqa.selenium.support.ui.ExpectedCondition; +import org.openqa.selenium.support.ui.ExpectedConditions; +import org.openqa.selenium.support.ui.Select; import org.testng.annotations.Test; -public class PaletteTest extends SeleniumTestCase{ +public class PaletteTest extends SeleniumTestCase2 { @Test - public void testPalette() - { + public void testPalette() throws InterruptedException { open("/ext/jquerypalette"); - waitForPageToLoad(); - final String avail = "identifier=handling-avail"; - final String select = "identifier=handling-select"; - final String deselect = "identifier=handling-deselect"; - final String selected = "identifier=handling-selected"; + final By avail = By.id("handling-avail"); + final By select = By.id("handling-select"); + final By deselect = By.id("handling-deselect"); - assertFalse(isEditable(select), select + " should not be clickable"); - assertFalse(isEditable(deselect), deselect + " should not be clickable"); + assertFalse(isEnabled(select), select + " should not be clickable"); + assertFalse(isEnabled(deselect), deselect + " should not be clickable"); focus(avail); - - addSelection(avail, "label=Gift Basket"); - doubleClick(avail); - - assertFalse(isEditable(select), select + " should not be clickable"); - assertTrue(isEditable(deselect), deselect + " should be clickable"); - click(deselect); + WebElement availElement = webDriver.findElement(avail); + + Select selectElement = new Select(availElement); + selectElement.selectByVisibleText("Gift Basket"); + Actions actions = new Actions(webDriver); + actions.doubleClick(availElement).perform(); + // Sometimes doubleClick may keep another option selected after action + selectElement.deselectAll(); - assertTrue(isEditable(select), select + " should be clickable"); - assertFalse(isEditable(deselect), deselect + " should not be clickable"); + assertFalse(isEnabled(select), select + " should not be clickable"); + assertTrue(isEnabled(deselect), deselect + " should be clickable"); + + click(deselect); - + assertTrue(isEnabled(select), select + " should be clickable"); + assertFalse(isEnabled(deselect), deselect + " should not be clickable"); } } diff --git a/src/test/java/org/got5/tapestry5/jquery/PlaceHolderTest.java b/src/test/java/org/got5/tapestry5/jquery/PlaceHolderTest.java index 412e7b13..60b6997c 100644 --- a/src/test/java/org/got5/tapestry5/jquery/PlaceHolderTest.java +++ b/src/test/java/org/got5/tapestry5/jquery/PlaceHolderTest.java @@ -1,11 +1,11 @@ package org.got5.tapestry5.jquery; -import org.apache.tapestry5.test.SeleniumTestCase; +import org.got5.tapestry5.jquery.test.SeleniumTestCase2; import org.testng.annotations.Test; import com.thoughtworks.selenium.Wait; -public class PlaceHolderTest extends SeleniumTestCase{ +public class PlaceHolderTest extends SeleniumTestCase2{ @Test public void tesPlaceholderAttribute(){ diff --git a/src/test/java/org/got5/tapestry5/jquery/RatyTest.java b/src/test/java/org/got5/tapestry5/jquery/RatyTest.java index c0ce3d2c..990a46c5 100644 --- a/src/test/java/org/got5/tapestry5/jquery/RatyTest.java +++ b/src/test/java/org/got5/tapestry5/jquery/RatyTest.java @@ -1,11 +1,11 @@ package org.got5.tapestry5.jquery; -import org.apache.tapestry5.test.SeleniumTestCase; +import org.got5.tapestry5.jquery.test.SeleniumTestCase2; import org.testng.annotations.Test; import com.thoughtworks.selenium.Wait; -public class RatyTest extends SeleniumTestCase{ +public class RatyTest extends SeleniumTestCase2{ @Test public void testReadOnly(){ diff --git a/src/test/java/org/got5/tapestry5/jquery/SelectorTest.java b/src/test/java/org/got5/tapestry5/jquery/SelectorTest.java index 69a4a120..fd7a4712 100644 --- a/src/test/java/org/got5/tapestry5/jquery/SelectorTest.java +++ b/src/test/java/org/got5/tapestry5/jquery/SelectorTest.java @@ -1,9 +1,9 @@ package org.got5.tapestry5.jquery; -import org.apache.tapestry5.test.SeleniumTestCase; +import org.got5.tapestry5.jquery.test.SeleniumTestCase2; import org.testng.annotations.Test; -public class SelectorTest extends SeleniumTestCase{ +public class SelectorTest extends SeleniumTestCase2{ @Test public void testSlider() diff --git a/src/test/java/org/got5/tapestry5/jquery/SortableTest.java b/src/test/java/org/got5/tapestry5/jquery/SortableTest.java index aea00324..c941a07a 100644 --- a/src/test/java/org/got5/tapestry5/jquery/SortableTest.java +++ b/src/test/java/org/got5/tapestry5/jquery/SortableTest.java @@ -1,11 +1,13 @@ package org.got5.tapestry5.jquery; -import org.apache.tapestry5.test.SeleniumTestCase; +import org.got5.tapestry5.jquery.test.SeleniumTestCase2; +import org.openqa.selenium.By; +import org.openqa.selenium.interactions.Actions; import org.testng.annotations.Test; import com.thoughtworks.selenium.Wait; -public class SortableTest extends SeleniumTestCase{ +public class SortableTest extends SeleniumTestCase2{ @Test public void testSortableMixin(){ @@ -24,9 +26,12 @@ public boolean until() getText("//ul[@id='any']/li[5]").equals("Ligne 5"); } }.wait("The default order is wrong!", JQueryTestConstants.TIMEOUT); - - dragAndDropToObject("//ul[@id='any']/li[5]", "//header"); - + + new Actions(webDriver).dragAndDropBy( + webDriver.findElement(By.xpath("//ul[@id='any']/li[5]")), + 0, -100 + ).perform(); + new Wait() { @Override @@ -39,8 +44,11 @@ public boolean until() getText("//ul[@id='any']/li[5]").equals("Ligne 4"); } }.wait("The second order is wrong!", JQueryTestConstants.TIMEOUT); - - dragAndDropToObject("//ul[@id='any']/li[3]", "//footer"); + + new Actions(webDriver).dragAndDropBy( + webDriver.findElement(By.xpath("//ul[@id='any']/li[3]")), + 0, 100 + ).perform(); new Wait() { diff --git a/src/test/java/org/got5/tapestry5/jquery/SuperfishTest.java b/src/test/java/org/got5/tapestry5/jquery/SuperfishTest.java index 7c18af8a..bfea77d6 100644 --- a/src/test/java/org/got5/tapestry5/jquery/SuperfishTest.java +++ b/src/test/java/org/got5/tapestry5/jquery/SuperfishTest.java @@ -1,11 +1,12 @@ package org.got5.tapestry5.jquery; -import org.apache.tapestry5.test.SeleniumTestCase; +import org.got5.tapestry5.jquery.test.SeleniumTestCase2; +import org.openqa.selenium.interactions.Actions; import org.testng.annotations.Test; import com.thoughtworks.selenium.Wait; -public class SuperfishTest extends SeleniumTestCase { +public class SuperfishTest extends SeleniumTestCase2 { private static final String SUPERFISH_MENU_SELECTOR = "//ul[@id='superfish']"; @@ -13,12 +14,12 @@ public class SuperfishTest extends SeleniumTestCase { private static final String SUPERFISH_MENU_THIRD_ITEM_SELECTOR = SUPERFISH_MENU_SELECTOR + "/li[3]/a"; - @Test + @Test public void testSuperfishComponent(){ - open("/SuperFish"); + open("/SuperFish"); - new Wait() + new Wait() { @Override public boolean until() @@ -28,7 +29,9 @@ public boolean until() }.wait("The ul element should have the sf-menu class : " + getAttribute(SUPERFISH_MENU_SELECTOR + "@class"), JQueryTestConstants.TIMEOUT); - click(SUPERFISH_MENU_FIRST_ITEM_SELECTOR); + new Actions(webDriver).moveToElement( + webDriver.findElement(convertLocator(SUPERFISH_MENU_FIRST_ITEM_SELECTOR)) + ).perform(); new Wait() { @@ -39,7 +42,9 @@ public boolean until() } }.wait("The ul element should have the sfHover class : " + getAttribute(SUPERFISH_MENU_SELECTOR + "[contains(@class,'sf-menu')]/li[1]@class"), JQueryTestConstants.TIMEOUT); - click(SUPERFISH_MENU_THIRD_ITEM_SELECTOR); + new Actions(webDriver).moveToElement( + webDriver.findElement(convertLocator(SUPERFISH_MENU_THIRD_ITEM_SELECTOR)) + ).perform(); new Wait() { diff --git a/src/test/java/org/got5/tapestry5/jquery/TabsTest.java b/src/test/java/org/got5/tapestry5/jquery/TabsTest.java index 8c633c78..bdec0b1f 100644 --- a/src/test/java/org/got5/tapestry5/jquery/TabsTest.java +++ b/src/test/java/org/got5/tapestry5/jquery/TabsTest.java @@ -1,11 +1,11 @@ package org.got5.tapestry5.jquery; -import org.apache.tapestry5.test.SeleniumTestCase; +import org.got5.tapestry5.jquery.test.SeleniumTestCase2; import org.testng.annotations.Test; import com.thoughtworks.selenium.Wait; -public class TabsTest extends SeleniumTestCase{ +public class TabsTest extends SeleniumTestCase2{ @Test public void testTabs() diff --git a/src/test/java/org/got5/tapestry5/jquery/TooltipTest.java b/src/test/java/org/got5/tapestry5/jquery/TooltipTest.java index d47e9412..045a2a3a 100644 --- a/src/test/java/org/got5/tapestry5/jquery/TooltipTest.java +++ b/src/test/java/org/got5/tapestry5/jquery/TooltipTest.java @@ -1,12 +1,12 @@ package org.got5.tapestry5.jquery; -import org.apache.tapestry5.test.SeleniumTestCase; +import org.got5.tapestry5.jquery.test.SeleniumTestCase2; import org.testng.annotations.BeforeTest; import org.testng.annotations.Test; import com.thoughtworks.selenium.Wait; -public class TooltipTest extends SeleniumTestCase{ +public class TooltipTest extends SeleniumTestCase2{ /** * Test Method for Tooltip mixin diff --git a/src/test/java/org/got5/tapestry5/jquery/TreeTest.java b/src/test/java/org/got5/tapestry5/jquery/TreeTest.java index c67fe61c..81901207 100644 --- a/src/test/java/org/got5/tapestry5/jquery/TreeTest.java +++ b/src/test/java/org/got5/tapestry5/jquery/TreeTest.java @@ -1,11 +1,11 @@ package org.got5.tapestry5.jquery; -import org.apache.tapestry5.test.SeleniumTestCase; +import org.got5.tapestry5.jquery.test.SeleniumTestCase2; import org.testng.annotations.Test; import com.thoughtworks.selenium.Wait; -public class TreeTest extends SeleniumTestCase{ +public class TreeTest extends SeleniumTestCase2{ @Test public void testTreeComponent(){ diff --git a/src/test/java/org/got5/tapestry5/jquery/ValidationTest.java b/src/test/java/org/got5/tapestry5/jquery/ValidationTest.java index 63f8f753..168e88bc 100644 --- a/src/test/java/org/got5/tapestry5/jquery/ValidationTest.java +++ b/src/test/java/org/got5/tapestry5/jquery/ValidationTest.java @@ -1,11 +1,11 @@ package org.got5.tapestry5.jquery; -import org.apache.tapestry5.test.SeleniumTestCase; +import org.got5.tapestry5.jquery.test.SeleniumTestCase2; import org.testng.annotations.Test; import com.thoughtworks.selenium.Wait; -public class ValidationTest extends SeleniumTestCase{ +public class ValidationTest extends SeleniumTestCase2{ @Test public void testValidation() diff --git a/src/test/java/org/got5/tapestry5/jquery/ZoneRefreshTest.java b/src/test/java/org/got5/tapestry5/jquery/ZoneRefreshTest.java index 399282b0..977a93e6 100644 --- a/src/test/java/org/got5/tapestry5/jquery/ZoneRefreshTest.java +++ b/src/test/java/org/got5/tapestry5/jquery/ZoneRefreshTest.java @@ -1,11 +1,11 @@ package org.got5.tapestry5.jquery; -import org.apache.tapestry5.test.SeleniumTestCase; +import org.got5.tapestry5.jquery.test.SeleniumTestCase2; import org.testng.annotations.Test; import com.thoughtworks.selenium.Wait; -public class ZoneRefreshTest extends SeleniumTestCase{ +public class ZoneRefreshTest extends SeleniumTestCase2{ @Test public void testZoneRefresh() throws Exception{ diff --git a/src/test/java/org/got5/tapestry5/jquery/ZoneTest.java b/src/test/java/org/got5/tapestry5/jquery/ZoneTest.java index 99680dbc..52ff501f 100644 --- a/src/test/java/org/got5/tapestry5/jquery/ZoneTest.java +++ b/src/test/java/org/got5/tapestry5/jquery/ZoneTest.java @@ -1,18 +1,18 @@ package org.got5.tapestry5.jquery; -import org.apache.tapestry5.test.SeleniumTestCase; +import org.got5.tapestry5.jquery.test.SeleniumTestCase2; import org.testng.annotations.Test; import com.thoughtworks.selenium.Wait; -public class ZoneTest extends SeleniumTestCase{ +public class ZoneTest extends SeleniumTestCase2{ @Test public void testZone() { open("/zone"); waitForPageToLoad(); - assertEquals(getText("identifier=myZone"), "Counting via AJAX : 0"); + assertEquals(getText("id=myZone"), "Counting via AJAX : 0"); click("//a[@data-update-zone='myZone']"); new Wait() @@ -23,7 +23,7 @@ public boolean until() return isTextPresent("Counting via AJAX : 1"); } }.wait("element not found", 5000l); - assertEquals(getText("identifier=myZone"), "Counting via AJAX : 1"); + assertEquals(getText("id=myZone"), "Counting via AJAX : 1"); } @Test @@ -31,9 +31,9 @@ public void testFormZone() { open("/zone"); waitForPageToLoad(); - assertEquals(getText("identifier=myZone2"), "Dummy value is :"); + assertEquals(getText("id=myZone2"), "Dummy value is :"); - type("identifier=textfield", "dummy"); + type("id=textfield", "dummy"); click("//form[@id='myForm']/input[@type='submit']"); new Wait() @@ -45,8 +45,8 @@ public boolean until() } }.wait("element not found", 5000l); - assertTrue(getText("identifier=myZone2").contains("Dummy value is : dummy") && - getText("identifier=myZone2").contains("I am a Component inside the block which is visible after the zone update")); + assertTrue(getText("id=myZone2").contains("Dummy value is : dummy") && + getText("id=myZone2").contains("I am a Component inside the block which is visible after the zone update")); } @Test(dependsOnMethods="testZone") @@ -54,10 +54,10 @@ public void testFormMultiZoneUpdate() { open("/zone"); waitForPageToLoad(); - assertEquals(getText("identifier=multiZone1"), "default zone content"); - assertEquals(getText("identifier=multiZone2"), "default zone content"); + assertEquals(getText("id=multiZone1"), "default zone content"); + assertEquals(getText("id=multiZone2"), "default zone content"); - click("identifier=multiSubmit"); + click("id=multiSubmit"); new Wait() { @@ -68,7 +68,7 @@ public boolean until() } }.wait("element not found", 5000l); - assertEquals(getText("identifier=multiZone1"), "rendering block-1 after multi zone update 2"); - assertEquals(getText("identifier=multiZone2"), "rendering block-2 after multi zone update 2"); + assertEquals(getText("id=multiZone1"), "rendering block-1 after multi zone update 2"); + assertEquals(getText("id=multiZone2"), "rendering block-2 after multi zone update 2"); } } diff --git a/src/test/java/org/got5/tapestry5/jquery/ZoneUpdaterTest.java b/src/test/java/org/got5/tapestry5/jquery/ZoneUpdaterTest.java index ed98177b..8e19a437 100644 --- a/src/test/java/org/got5/tapestry5/jquery/ZoneUpdaterTest.java +++ b/src/test/java/org/got5/tapestry5/jquery/ZoneUpdaterTest.java @@ -1,27 +1,35 @@ package org.got5.tapestry5.jquery; -import org.apache.tapestry5.test.SeleniumTestCase; +import org.got5.tapestry5.jquery.test.SeleniumTestCase2; import org.openqa.selenium.Keys; +import org.openqa.selenium.WebElement; +import org.openqa.selenium.interactions.Actions; import org.testng.annotations.Test; import com.thoughtworks.selenium.Wait; -public class ZoneUpdaterTest extends SeleniumTestCase { +public class ZoneUpdaterTest extends SeleniumTestCase2 { - @Test(groups="whatevs") + @Test public void testZoneUpdater(){ open("/ZoneUpdater"); - waitForPageToLoad(); + + Actions actions = new Actions(webDriver); + assertTrue(isElementPresent("//div[@id='nameZone'][contains(text(), 'Humpty Dumpty')]")); - click("//input[@type='text'][@id='firstName']"); - focus("//input[@type='text'][@id='firstName']"); - type("//input[@type='text'][@id='firstName']", "Hempster"); - keyPress("//input[@type='text'][@id='firstName']", Keys.TAB.toString()); - click("//input[@type='text'][@id='lastName']"); - focus("//input[@type='text'][@id='lastName']"); - type("//input[@type='text'][@id='lastName']", "Dempster"); - keyPress("//input[@type='text'][@id='lastName']", Keys.TAB.toString()); + + WebElement firstName = webDriver.findElement(convertLocator("//input[@type='text'][@id='firstName']")); + WebElement lastName = webDriver.findElement(convertLocator("//input[@type='text'][@id='lastName']")); + + firstName.clear(); + actions.sendKeys(firstName, "Hempster").perform(); + + waitForAjaxRequestsToComplete(); + + lastName.clear(); + actions.sendKeys(lastName, "Dempster").perform(); + new Wait() { @Override public boolean until() { diff --git a/src/test/java/org/got5/tapestry5/jquery/pages/CalendarInZone.java b/src/test/java/org/got5/tapestry5/jquery/pages/CalendarInZone.java index 87bbf698..d26d254b 100644 --- a/src/test/java/org/got5/tapestry5/jquery/pages/CalendarInZone.java +++ b/src/test/java/org/got5/tapestry5/jquery/pages/CalendarInZone.java @@ -1,8 +1,5 @@ package org.got5.tapestry5.jquery.pages; -import java.util.Date; -import java.util.Locale; - import org.apache.tapestry5.annotations.InjectComponent; import org.apache.tapestry5.annotations.OnEvent; import org.apache.tapestry5.annotations.Persist; @@ -11,6 +8,9 @@ import org.apache.tapestry5.ioc.annotations.Inject; import org.apache.tapestry5.services.PersistentLocale; +import java.util.Date; +import java.util.Locale; + public class CalendarInZone { @Property diff --git a/src/test/java/org/got5/tapestry5/jquery/test/SeleniumTestCase2.java b/src/test/java/org/got5/tapestry5/jquery/test/SeleniumTestCase2.java new file mode 100644 index 00000000..840d5d0f --- /dev/null +++ b/src/test/java/org/got5/tapestry5/jquery/test/SeleniumTestCase2.java @@ -0,0 +1,174 @@ +package org.got5.tapestry5.jquery.test; + +import org.apache.tapestry5.test.SeleniumTestCase; +import org.apache.tapestry5.test.TapestryTestConfiguration; +import org.got5.tapestry5.jquery.JQueryTestConstants; +import org.openqa.selenium.*; +import org.openqa.selenium.interactions.Actions; +import org.openqa.selenium.support.ui.ExpectedCondition; +import org.openqa.selenium.support.ui.ExpectedConditions; +import org.openqa.selenium.support.ui.WebDriverWait; + +import java.time.Duration; +import java.util.List; +import java.util.concurrent.TimeUnit; +import java.util.function.Predicate; + +import static java.util.Collections.emptyList; +import static java.util.stream.Collectors.toList; +import static org.apache.commons.lang3.StringUtils.startsWithIgnoreCase; + +@TapestryTestConfiguration(webAppFolder = "src/test/webapp") +public class SeleniumTestCase2 extends SeleniumTestCase +{ + protected WebElement findFirstVisible(WebDriver webDriver, By by) + { + return webDriver.findElements(by) + .stream() + .filter(WebElement::isDisplayed) + .findFirst() + .orElseThrow(() -> new NoSuchElementException("Unable to find visible element by " + by)); + } + + protected void click(WebElement element) + { + this.scrollIntoView(element); + JavascriptExecutor executor = (JavascriptExecutor)this.webDriver; + executor.executeScript("arguments[0].click();", element); + } + + protected void click(By locator) + { + click(webDriver.findElement(locator)); + } + + protected void clickAndWait(WebElement element) + { + click(element); + waitForPageToLoad(); + } + + protected void assertNotPresent(By locator, String message) + { + assertNotPresent(locator, __ -> true, message); + } + + protected void assertNotPresent(By locator, Predicate filter, String message) + { + List elements = webDriver.findElements(locator).stream().filter(filter).collect(toList()); + assertEquals(elements, emptyList(), message); + } + + protected void waitForCondition(ExpectedCondition> condition, String message) + { + try + { + super.waitForCondition(condition, JQueryTestConstants.TIMEOUT / 1000); + } + catch (TimeoutException e) + { + throw new TimeoutException(message, e); + } + } + + @Override + public void open(String url) + { + boolean absoluteUrl = startsWithIgnoreCase(url, "http://") || startsWithIgnoreCase(url, "https://"); + + if (!absoluteUrl) + { + url = getBaseURL() + (url.startsWith("/") ? url.substring(1) : url); + } + + webDriver.navigate().to(url); + + waitForPageInitialized(Duration.ofMillis(JQueryTestConstants.TIMEOUT)); + } + + protected void waitForPageInitialized(Duration timeout) + { + long startTime = System.currentTimeMillis(); + + waitForDocumentReady(timeout); + + // 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. + try + { + WebElement body = webDriver.findElement(By.cssSelector("body")); + + // Not a tapestry page? + if (body.getAttribute("data-page-initialized") == null) + { + return; + } + + long timePassed = System.currentTimeMillis() - startTime; + + Duration timeLeft = Duration.ofMillis(timeout.toMillis() - timePassed); + + waitForVisible(By.cssSelector("body[data-page-initialized='true']"), timeLeft); + } + catch (NoSuchElementException e) + { + // no body element found, there's nothing to wait for + } + } + + protected void waitForVisible(By locator, Duration timeout) + { + waitForCondition(ExpectedConditions.visibilityOfElementLocated(locator), timeout.getSeconds()); + } + + private void waitForDocumentReady(Duration timeout) + { + new WebDriverWait(webDriver, timeout.getSeconds()) + .until(webDriver -> + ((JavascriptExecutor) webDriver) + .executeScript("return document.readyState") + .equals("complete")); + } + + protected boolean isEnabled(By locator) + { + return webDriver.findElement(locator).isEnabled(); + } + + protected void focus(By locator) + { + new Actions(webDriver).moveToElement(webDriver.findElement(locator)); + } + + @Override + public void focus(String locator) + { + focus(convertLocator(locator)); + } + + @Override + public void keyDown(String locator, String keySequence) + { + WebElement element = webDriver.findElement(convertLocator(locator)); + Actions actions = new Actions(webDriver); + + keySequence.chars().forEach(ch -> + actions + .keyDown(element, Keys.getKeyFromUnicode((char) ch)) + .perform()); + } + + + @Override + public void keyUp(String locator, String keySequence) + { + WebElement element = webDriver.findElement(convertLocator(locator)); + Actions actions = new Actions(webDriver); + + keySequence.chars().forEach(ch -> + actions + .keyUp(element, Keys.getKeyFromUnicode((char) ch)) + .perform()); + } +} \ No newline at end of file diff --git a/src/test/resources/logback-test.xml b/src/test/resources/logback-test.xml new file mode 100644 index 00000000..aebedf0a --- /dev/null +++ b/src/test/resources/logback-test.xml @@ -0,0 +1,13 @@ + + + + + %d{HH:mm:ss.SSS} %X{req.sessionId} [%thread] %7X{req.requestId} %-5level %logger{36} - %msg%n + + + + + + + + diff --git a/src/test/resources/org/got5/tapestry5/jquery/pages/JQueryConfirm.tml b/src/test/resources/org/got5/tapestry5/jquery/pages/JQueryConfirm.tml index b7a6a9e5..c734e52b 100644 --- a/src/test/resources/org/got5/tapestry5/jquery/pages/JQueryConfirm.tml +++ b/src/test/resources/org/got5/tapestry5/jquery/pages/JQueryConfirm.tml @@ -8,7 +8,7 @@ - PageLink confirmation test + PageLink confirmation test diff --git a/src/test/resources/org/got5/tapestry5/jquery/pages/JScrollPane.tml b/src/test/resources/org/got5/tapestry5/jquery/pages/JScrollPane.tml index 968a9389..30faece4 100644 --- a/src/test/resources/org/got5/tapestry5/jquery/pages/JScrollPane.tml +++ b/src/test/resources/org/got5/tapestry5/jquery/pages/JScrollPane.tml @@ -12,8 +12,13 @@ .horizontal-only { height: auto; - max-height: 200px; + max-width: 200px; } + +.both { + max-width: 200px; +} + @@ -108,7 +113,7 @@ viverra. Both - + Lorem ipsum dolor sit amet, consectetur adipiscing elit. Donec in ligula id sem tristique ultrices eget id neque. Duis enim turpis, tempus at accumsan vitae, lobortis id
Lorem ipsum dolor sit amet, consectetur adipiscing elit. Donec in ligula id sem tristique ultrices eget id neque. Duis enim turpis, tempus at accumsan vitae, lobortis id