diff options
author | Artur <artur@vaadin.com> | 2017-07-27 13:41:17 +0300 |
---|---|---|
committer | Henri Sara <henri.sara@gmail.com> | 2017-07-27 13:41:17 +0300 |
commit | 390fd31dc18d026a60a89e9b5cba040859cc3393 (patch) | |
tree | 734b3de37b021f541ef209d9b72fb567ec0cdd66 /testbench-api/src/main/java | |
parent | 410965ddca3e601343f8b759e1a27a2c1b0d0f29 (diff) | |
download | vaadin-framework-390fd31dc18d026a60a89e9b5cba040859cc3393.tar.gz vaadin-framework-390fd31dc18d026a60a89e9b5cba040859cc3393.zip |
Implement GWT Focusable so tab indexes work correctly in MenuBar (#9733)
Fixes #9550
Diffstat (limited to 'testbench-api/src/main/java')
6 files changed, 100 insertions, 13 deletions
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 <input>} 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 <select>} element inside the component. + * + * @return the select element inside the component + * @since + */ + public WebElement getSelectElement() { + return selectElement; + } + } diff --git a/testbench-api/src/main/java/com/vaadin/testbench/elements/NativeSelectElement.java b/testbench-api/src/main/java/com/vaadin/testbench/elements/NativeSelectElement.java index 99becf125e..7476cad6b5 100644 --- a/testbench-api/src/main/java/com/vaadin/testbench/elements/NativeSelectElement.java +++ b/testbench-api/src/main/java/com/vaadin/testbench/elements/NativeSelectElement.java @@ -17,6 +17,7 @@ package com.vaadin.testbench.elements; import java.util.List; +import org.openqa.selenium.WebElement; import org.openqa.selenium.support.ui.Select; import com.vaadin.testbench.By; @@ -25,23 +26,35 @@ import com.vaadin.testbench.elementsbase.ServerClass; @ServerClass("com.vaadin.ui.NativeSelect") public class NativeSelectElement extends AbstractSelectElement { - private Select selectElement; + private Select select; + private WebElement selectElement; @Override protected void init() { super.init(); - selectElement = new Select(findElement(By.tagName("select"))); + selectElement = findElement(By.tagName("select")); + select = new Select(selectElement); + } + + /** + * Gets the {@code <select>} element inside the component. + * + * @return the select element inside the component + * @since + */ + public WebElement getSelectElement() { + return selectElement; } public List<TestBenchElement> 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 <iframe>} element inside the component, containing the + * editor. + * + * @return the iframe element containing the editor + * @since + */ + public WebElement getEditorIframe() { + return findElement(By.tagName("iframe")); + } } diff --git a/testbench-api/src/main/java/com/vaadin/testbench/elements/TwinColSelectElement.java b/testbench-api/src/main/java/com/vaadin/testbench/elements/TwinColSelectElement.java index 7f3859c146..3705636b55 100644 --- a/testbench-api/src/main/java/com/vaadin/testbench/elements/TwinColSelectElement.java +++ b/testbench-api/src/main/java/com/vaadin/testbench/elements/TwinColSelectElement.java @@ -33,13 +33,19 @@ public class TwinColSelectElement extends AbstractSelectElement { private WebElement selButton; private static org.openqa.selenium.By bySelect = By.tagName("select"); private static org.openqa.selenium.By byButton = By.className("v-button"); + private WebElement optionsElement; + private WebElement selectionsElement; @Override protected void init() { super.init(); List<WebElement> selectElements = findElements(bySelect); - options = new Select(selectElements.get(0)); - selectedOptions = new Select(selectElements.get(1)); + + optionsElement = selectElements.get(0); + selectionsElement = selectElements.get(1); + + options = new Select(optionsElement); + selectedOptions = new Select(selectionsElement); List<WebElement> buttons = findElements(byButton); selButton = buttons.get(0); deselButton = buttons.get(1); @@ -154,4 +160,26 @@ public class TwinColSelectElement extends AbstractSelectElement { public void clear() { deselectAll(); } + + /** + * Gets the left {@code <select>} element inside the component, containing + * the available options. + * + * @return the select element containing options inside the component + * @since + */ + public WebElement getOptionsElement() { + return optionsElement; + } + + /** + * Gets the right {@code <select>} element inside the component, containing + * the selected options. + * + * @return the select element containing selection inside the component + * @since + */ + public WebElement getSelectionsElement() { + return selectionsElement; + } } |