Repository: tapestry-5 Updated Branches: refs/heads/master bd2c277f3 -> 012789962
extract and re-use Project: http://git-wip-us.apache.org/repos/asf/tapestry-5/repo Commit: http://git-wip-us.apache.org/repos/asf/tapestry-5/commit/01278996 Tree: http://git-wip-us.apache.org/repos/asf/tapestry-5/tree/01278996 Diff: http://git-wip-us.apache.org/repos/asf/tapestry-5/diff/01278996 Branch: refs/heads/master Commit: 0127899628c823a9d588999595e867d8f2f3fae7 Parents: bd2c277 Author: Jochen Kemnade <[email protected]> Authored: Thu Nov 2 16:33:14 2017 +0100 Committer: Jochen Kemnade <[email protected]> Committed: Fri Nov 3 07:58:15 2017 +0100 ---------------------------------------------------------------------- .../tapestry5/integration/app1/AjaxGroovyTests.groovy | 4 +++- .../org/apache/tapestry5/integration/app1/FormTests.java | 5 ++++- .../java/org/apache/tapestry5/test/SeleniumTestCase.java | 10 ++++++++-- 3 files changed, 15 insertions(+), 4 deletions(-) ---------------------------------------------------------------------- http://git-wip-us.apache.org/repos/asf/tapestry-5/blob/01278996/tapestry-core/src/test/groovy/org/apache/tapestry5/integration/app1/AjaxGroovyTests.groovy ---------------------------------------------------------------------- diff --git a/tapestry-core/src/test/groovy/org/apache/tapestry5/integration/app1/AjaxGroovyTests.groovy b/tapestry-core/src/test/groovy/org/apache/tapestry5/integration/app1/AjaxGroovyTests.groovy index 209281a..1b129ee 100644 --- a/tapestry-core/src/test/groovy/org/apache/tapestry5/integration/app1/AjaxGroovyTests.groovy +++ b/tapestry-core/src/test/groovy/org/apache/tapestry5/integration/app1/AjaxGroovyTests.groovy @@ -12,7 +12,9 @@ class AjaxGroovyTests extends App1TestCase { openLinks "Ajax Radio Demo" webDriver.findElements(By.cssSelector('label')).find{it.text.contains('It')}.click() - webDriver.findElements(By.cssSelector('label')).find{it.text.contains('Temp')}.click() + def labelTemp = webDriver.findElements(By.cssSelector('label')).find{it.text.contains('Temp')} + scrollIntoView(labelTemp) + labelTemp.click() click SUBMIT http://git-wip-us.apache.org/repos/asf/tapestry-5/blob/01278996/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 b666012..54d96a2 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 @@ -17,6 +17,7 @@ import java.util.Date; import org.apache.tapestry5.corelib.components.Form; import org.openqa.selenium.By; +import org.openqa.selenium.WebElement; import org.openqa.selenium.support.ui.ExpectedCondition; import org.openqa.selenium.support.ui.ExpectedConditions; import org.testng.annotations.Test; @@ -451,7 +452,9 @@ public class FormTests extends App1TestCase assertTextPresent("Selected department: ACCOUNTING"); - webDriver.findElements(By.cssSelector("label")).stream().filter(element-> element.getText().contains("Sales And Marketin")).findFirst().get().click(); + WebElement salesAndMarketing = webDriver.findElements(By.cssSelector("label")).stream().filter(element-> element.getText().contains("Sales And Marketin")).findFirst().get(); + scrollIntoView(salesAndMarketing); + salesAndMarketing.click(); clickAndWait(update); http://git-wip-us.apache.org/repos/asf/tapestry-5/blob/01278996/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 f318733..313e4e5 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 @@ -544,7 +544,7 @@ public abstract class SeleniumTestCase extends Assert implements Selenium WebElement element = webDriver.findElement(convertLocator(locator)); if (!element.isSelected()) { - ((JavascriptExecutor) webDriver).executeScript("arguments[0].scrollIntoView(true);", element); + scrollIntoView(element); element.click(); } } @@ -565,7 +565,7 @@ public abstract class SeleniumTestCase extends Assert implements Selenium public void click(String locator) { WebElement element = webDriver.findElement(convertLocator(locator)); - ((JavascriptExecutor) webDriver).executeScript("arguments[0].scrollIntoView(true);", element); + scrollIntoView(element); element.click(); } @@ -1426,6 +1426,12 @@ public abstract class SeleniumTestCase extends Assert implements Selenium // End of delegate methods // --------------------------------------------------------------------- + + public void scrollIntoView(WebElement element) + { + ((JavascriptExecutor) webDriver).executeScript("arguments[0].scrollIntoView(true);", element); + } + /** * Formats a message from the provided arguments, which is written to System.err. In addition, * captures the AUT's markup, screenshot, and a report to the output directory.
