From 390fd31dc18d026a60a89e9b5cba040859cc3393 Mon Sep 17 00:00:00 2001 From: Artur Date: Thu, 27 Jul 2017 13:41:17 +0300 Subject: Implement GWT Focusable so tab indexes work correctly in MenuBar (#9733) Fixes #9550 --- .../testbench/elements/DateFieldElement.java | 17 +++++++++--- .../testbench/elements/InlineDateFieldElement.java | 13 +++++++++ .../testbench/elements/ListSelectElement.java | 10 +++++++ .../testbench/elements/NativeSelectElement.java | 27 +++++++++++++----- .../testbench/elements/RichTextAreaElement.java | 14 ++++++++++ .../testbench/elements/TwinColSelectElement.java | 32 ++++++++++++++++++++-- 6 files changed, 100 insertions(+), 13 deletions(-) (limited to 'testbench-api') diff --git a/testbench-api/src/main/java/com/vaadin/testbench/elements/DateFieldElement.java b/testbench-api/src/main/java/com/vaadin/testbench/elements/DateFieldElement.java index 503eb1ca03..6557ca792b 100644 --- a/testbench-api/src/main/java/com/vaadin/testbench/elements/DateFieldElement.java +++ b/testbench-api/src/main/java/com/vaadin/testbench/elements/DateFieldElement.java @@ -36,8 +36,7 @@ public class DateFieldElement extends AbstractDateFieldElement { */ @Override public void clear() { - WebElement elem = findElement(By.tagName("input")); - elem.clear(); + getInputElement().clear(); } /** @@ -46,7 +45,7 @@ public class DateFieldElement extends AbstractDateFieldElement { * @return value of the date field element */ public String getValue() { - return findElement(By.tagName("input")).getAttribute("value"); + return getInputElement().getAttribute("value"); } /** @@ -61,7 +60,7 @@ public class DateFieldElement extends AbstractDateFieldElement { if (isReadOnly()) { throw new ReadOnlyException(); } - WebElement elem = findElement(By.tagName("input")); + WebElement elem = getInputElement(); TestBenchElement tbElement = (TestBenchElement) elem; clearElementClientSide(tbElement); tbElement.sendKeys(chars); @@ -109,4 +108,14 @@ public class DateFieldElement extends AbstractDateFieldElement { return DateTimeFormatter.ISO_LOCAL_DATE; } + /** + * Gets the {@code } element inside the component. + * + * @return the input element inside the component + * @since + */ + public WebElement getInputElement() { + return findElement(By.tagName("input")); + } + } diff --git a/testbench-api/src/main/java/com/vaadin/testbench/elements/InlineDateFieldElement.java b/testbench-api/src/main/java/com/vaadin/testbench/elements/InlineDateFieldElement.java index 959b723ed8..7c5a2d61eb 100644 --- a/testbench-api/src/main/java/com/vaadin/testbench/elements/InlineDateFieldElement.java +++ b/testbench-api/src/main/java/com/vaadin/testbench/elements/InlineDateFieldElement.java @@ -15,6 +15,9 @@ */ package com.vaadin.testbench.elements; +import org.openqa.selenium.By; +import org.openqa.selenium.WebElement; + import com.vaadin.testbench.elementsbase.ServerClass; /** @@ -23,4 +26,14 @@ import com.vaadin.testbench.elementsbase.ServerClass; @ServerClass("com.vaadin.ui.InlineDateField") public class InlineDateFieldElement extends AbstractFieldElement { + /** + * Returns the element which receives focus when the component is focused. + * + * @return the element which receives focus when the component is focused + * @since + */ + public WebElement getFocusElement() { + return findElement(By.tagName("table")); + + } } diff --git a/testbench-api/src/main/java/com/vaadin/testbench/elements/ListSelectElement.java b/testbench-api/src/main/java/com/vaadin/testbench/elements/ListSelectElement.java index 77660904f3..1090060a07 100644 --- a/testbench-api/src/main/java/com/vaadin/testbench/elements/ListSelectElement.java +++ b/testbench-api/src/main/java/com/vaadin/testbench/elements/ListSelectElement.java @@ -123,4 +123,14 @@ public class ListSelectElement extends AbstractSelectElement { } + /** + * Gets the {@code } element inside the component. + * + * @return the select element inside the component + * @since + */ + public WebElement getSelectElement() { + return selectElement; } public List getOptions() { - return wrapElements(selectElement.getOptions(), getCommandExecutor()); + return wrapElements(select.getOptions(), getCommandExecutor()); } public void selectByText(String text) throws ReadOnlyException { if (isReadOnly()) { throw new ReadOnlyException(); } - selectElement.selectByVisibleText(text); + select.selectByVisibleText(text); waitForVaadin(); } @@ -55,16 +68,16 @@ public class NativeSelectElement extends AbstractSelectElement { } /** - * Return value of the selected item in the native select element + * Return value of the selected item in the native select element. * * @return value of the selected item in the native select element */ public String getValue() { - return selectElement.getFirstSelectedOption().getText(); + return select.getFirstSelectedOption().getText(); } /** - * Select item of the native select element with the specified value + * Select item of the native select element with the specified value. * * @param chars * value of the native select item will be selected diff --git a/testbench-api/src/main/java/com/vaadin/testbench/elements/RichTextAreaElement.java b/testbench-api/src/main/java/com/vaadin/testbench/elements/RichTextAreaElement.java index d5cc9e9a8a..780c808271 100644 --- a/testbench-api/src/main/java/com/vaadin/testbench/elements/RichTextAreaElement.java +++ b/testbench-api/src/main/java/com/vaadin/testbench/elements/RichTextAreaElement.java @@ -15,8 +15,22 @@ */ package com.vaadin.testbench.elements; +import org.openqa.selenium.WebElement; + +import com.vaadin.testbench.By; import com.vaadin.testbench.elementsbase.ServerClass; @ServerClass("com.vaadin.ui.RichTextArea") public class RichTextAreaElement extends AbstractFieldElement { + + /** + * Gets the {@code