aboutsummaryrefslogtreecommitdiffstats
path: root/uitest-common
diff options
context:
space:
mode:
authorTeemu Suo-Anttila <tsuoanttila@users.noreply.github.com>2017-01-13 09:32:41 +0200
committerPekka Hyvönen <pekka@vaadin.com>2017-01-13 09:32:41 +0200
commit253a61c1957941759deff87518989a71c30fc301 (patch)
tree90f26a96533daade29e536137efe5433144ac2cd /uitest-common
parentfd8696de945b8a3f3fa954ed56b4a48e3060d50a (diff)
downloadvaadin-framework-253a61c1957941759deff87518989a71c30fc301.tar.gz
vaadin-framework-253a61c1957941759deff87518989a71c30fc301.zip
Fix TestBench API imports (#8112)
* Fix TestBench API imports, move functionality from custom elements * Fixes to TestBench APIs and JavaDocs * Merge remote-tracking branch 'origin/master' into 578_tbapi_cleanup * Fix method name in CheckBoxGroupTest * Remove unused custom element classes * Implement getOptions using getOptionElements * Replace setValue with setSelection in CheckBoxGroupElement * Rename CheckBoxGroupElement getSelection to getValue * Fix one last method
Diffstat (limited to 'uitest-common')
-rw-r--r--uitest-common/src/main/java/com/vaadin/testbench/customelements/CalendarElement.java57
-rw-r--r--uitest-common/src/main/java/com/vaadin/testbench/customelements/CheckBoxGroupElement.java99
-rw-r--r--uitest-common/src/main/java/com/vaadin/testbench/customelements/ComboBoxElement.java63
-rw-r--r--uitest-common/src/main/java/com/vaadin/testbench/customelements/FixedNotificationElement.java28
-rw-r--r--uitest-common/src/main/java/com/vaadin/testbench/customelements/GridElement.java32
-rw-r--r--uitest-common/src/main/java/com/vaadin/testbench/customelements/MenuBarElement.java15
-rw-r--r--uitest-common/src/main/java/com/vaadin/testbench/customelements/NativeSelectElement.java76
-rw-r--r--uitest-common/src/main/java/com/vaadin/testbench/customelements/ProgressBarElement.java39
-rw-r--r--uitest-common/src/main/java/com/vaadin/testbench/customelements/RadioButtonGroupElement.java73
-rw-r--r--uitest-common/src/main/java/com/vaadin/testbench/customelements/TableElement.java24
-rw-r--r--uitest-common/src/main/java/com/vaadin/testbench/customelements/WindowElement.java75
11 files changed, 0 insertions, 581 deletions
diff --git a/uitest-common/src/main/java/com/vaadin/testbench/customelements/CalendarElement.java b/uitest-common/src/main/java/com/vaadin/testbench/customelements/CalendarElement.java
deleted file mode 100644
index 627e579ef7..0000000000
--- a/uitest-common/src/main/java/com/vaadin/testbench/customelements/CalendarElement.java
+++ /dev/null
@@ -1,57 +0,0 @@
-package com.vaadin.testbench.customelements;
-
-import java.util.List;
-
-import org.openqa.selenium.WebElement;
-
-import com.vaadin.testbench.By;
-import com.vaadin.testbench.elementsbase.ServerClass;
-
-@ServerClass("com.vaadin.ui.Calendar")
-public class CalendarElement
- extends com.vaadin.testbench.elements.CalendarElement {
- @Override
- public List<WebElement> getWeekNumbers() {
- return findElements(By.className("v-calendar-week-number"));
- }
-
- @Override
- public boolean hasMonthView() {
- return isElementPresent(By.className("v-calendar-week-numbers"));
- }
-
- @Override
- public boolean hasWeekView() {
- return isElementPresent(By.className("v-calendar-header-week"));
- }
-
- @Override
- public List<WebElement> getDayNumbers() {
- return findElements(By.className("v-calendar-day-number"));
- }
-
- @Override
- public List<WebElement> getMonthDays() {
- return findElements(By.className("v-calendar-month-day"));
- }
-
- @Override
- public boolean hasDayView() {
- return getDayHeaders().size() == 1;
- }
-
- @Override
- public List<WebElement> getDayHeaders() {
- return findElements(By.className("v-calendar-header-day"));
- }
-
- @Override
- public void back() {
- findElement(By.className("v-calendar-back")).click();
- }
-
- @Override
- public void next() {
- findElement(By.className("v-calendar-next")).click();
- }
-}
diff --git a/uitest-common/src/main/java/com/vaadin/testbench/customelements/CheckBoxGroupElement.java b/uitest-common/src/main/java/com/vaadin/testbench/customelements/CheckBoxGroupElement.java
deleted file mode 100644
index e8a05cb194..0000000000
--- a/uitest-common/src/main/java/com/vaadin/testbench/customelements/CheckBoxGroupElement.java
+++ /dev/null
@@ -1,99 +0,0 @@
-/*
- * Copyright 2000-2014 Vaadin Ltd.
- *
- * Licensed under the Apache License, Version 2.0 (the "License"); you may not
- * use this file except in compliance with the License. You may obtain a copy of
- * the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
- * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
- * License for the specific language governing permissions and limitations under
- * the License.
- */
-package com.vaadin.testbench.customelements;
-
-import java.util.ArrayList;
-import java.util.List;
-
-import org.openqa.selenium.WebElement;
-
-import com.vaadin.testbench.By;
-
-/**
- * TestBench element supporting CheckBoxGroup
- *
- * @author Vaadin Ltd
- */
-public class CheckBoxGroupElement
- extends com.vaadin.testbench.elements.CheckBoxGroupElement {
- private static org.openqa.selenium.By byButtonSpan = By
- .className("v-select-option");
- private static org.openqa.selenium.By byLabel = By.tagName("label");
- private static org.openqa.selenium.By byInput = By.tagName("input");
-
- public List<String> getOptionsCssClasses() {
- List<String> optionTexts = new ArrayList<>();
- List<WebElement> options = findElements(byButtonSpan);
- for (WebElement option : options) {
- optionTexts.add(option.getAttribute("class"));
- }
- return optionTexts;
- }
-
- public List<String> getOptionsIconUrls() {
- List<String> icons = new ArrayList<>();
- List<WebElement> options = findElements(byButtonSpan);
- for (WebElement option : options) {
- List<WebElement> images = option.findElements(By.tagName("img"));
- if (images != null && images.size() > 0) {
- icons.add(images.get(0).getAttribute("src"));
- } else {
- icons.add(null);
- }
-
- }
- return icons;
- }
-
- /**
- * Return list of the selected options in the checkbox group
- *
- * @return list of the selected options in the checkbox group
- */
- public List<String> getSelection() {
- List<String> values = new ArrayList<>();
- List<WebElement> options = findElements(byButtonSpan);
- for (WebElement option : options) {
- WebElement checkedItem;
- checkedItem = option.findElement(By.tagName("input"));
- String checked = checkedItem.getAttribute("checked");
- if (checked != null
- && checkedItem.getAttribute("checked").equals("true")) {
- values.add(option.findElement(By.tagName("label")).getText());
- }
- }
- return values;
- }
-
- /**
- * Select option in the checkbox group with the specified value
- *
- * @param chars
- * value of the option in the checkbox group which will be
- * selected
- */
- public void selectOption(CharSequence chars) throws ReadOnlyException {
- selectByText((String) chars);
- }
-
- @Override
- public void clear() {
- throw new UnsupportedOperationException(
- "Clear operation is not supported for CheckBoxGroup."
- + " This operation has no effect on the element.");
- }
-
-}
diff --git a/uitest-common/src/main/java/com/vaadin/testbench/customelements/ComboBoxElement.java b/uitest-common/src/main/java/com/vaadin/testbench/customelements/ComboBoxElement.java
deleted file mode 100644
index 89bddf309f..0000000000
--- a/uitest-common/src/main/java/com/vaadin/testbench/customelements/ComboBoxElement.java
+++ /dev/null
@@ -1,63 +0,0 @@
-package com.vaadin.testbench.customelements;
-
-import org.junit.Assert;
-import org.openqa.selenium.WebElement;
-
-import com.vaadin.testbench.By;
-import com.vaadin.testbench.elementsbase.ServerClass;
-
-@ServerClass("com.vaadin.ui.ComboBox")
-public class ComboBoxElement
- extends com.vaadin.testbench.elements.ComboBoxElement {
-
- private static org.openqa.selenium.By bySuggestionPopup = By
- .vaadin("#popup");
-
- @Override
- public WebElement getInputField() {
- return findElement(By.vaadin("#textbox"));
- }
-
- @Override
- public String getText() {
- return getInputField().getAttribute("value");
- }
-
- @Override
- public void clear() {
- getInputField().clear();
- }
-
- @Override
- public WebElement getSuggestionPopup() {
- return findElement(bySuggestionPopup);
- }
-
- @Override
- public void sendKeys(CharSequence... keysToSend) {
- sendKeys(50, keysToSend);
- }
-
- /**
- * Use this method to simulate typing into an element, which may set its
- * value.
- *
- * @param delay
- * delay after sending each individual key (mainly needed for
- * PhantomJS)
- * @param keysToSend
- * keys to type into the element
- */
- public void sendKeys(int delay, CharSequence... keysToSend) {
- WebElement input = getInputField();
-
- for (CharSequence key : keysToSend) {
- input.sendKeys(key);
- try {
- Thread.sleep(delay);
- } catch (InterruptedException e) {
- Assert.fail(e.getMessage());
- }
- }
- }
-}
diff --git a/uitest-common/src/main/java/com/vaadin/testbench/customelements/FixedNotificationElement.java b/uitest-common/src/main/java/com/vaadin/testbench/customelements/FixedNotificationElement.java
deleted file mode 100644
index 696cbeb95c..0000000000
--- a/uitest-common/src/main/java/com/vaadin/testbench/customelements/FixedNotificationElement.java
+++ /dev/null
@@ -1,28 +0,0 @@
-package com.vaadin.testbench.customelements;
-
-import org.openqa.selenium.WebElement;
-import org.openqa.selenium.support.ui.ExpectedConditions;
-import org.openqa.selenium.support.ui.WebDriverWait;
-
-import com.vaadin.testbench.By;
-import com.vaadin.testbench.elements.NotificationElement;
-import com.vaadin.testbench.elementsbase.ServerClass;
-
-@ServerClass("com.vaadin.ui.Notification")
-public class FixedNotificationElement extends NotificationElement {
- @Override
- public String getCaption() {
- WebElement popup = findElement(By.className("popupContent"));
- WebElement caption = popup.findElement(By.tagName("h1"));
- return caption.getText();
- }
-
- @Override
- public void close() {
- click(5, 5);
- WebDriverWait wait = new WebDriverWait(getDriver(), 10);
- wait.until(ExpectedConditions
- .not(ExpectedConditions.presenceOfAllElementsLocatedBy(
- By.className("v-Notification"))));
- }
-}
diff --git a/uitest-common/src/main/java/com/vaadin/testbench/customelements/GridElement.java b/uitest-common/src/main/java/com/vaadin/testbench/customelements/GridElement.java
deleted file mode 100644
index f0ba310023..0000000000
--- a/uitest-common/src/main/java/com/vaadin/testbench/customelements/GridElement.java
+++ /dev/null
@@ -1,32 +0,0 @@
-package com.vaadin.testbench.customelements;
-
-import org.openqa.selenium.NoSuchElementException;
-
-import com.vaadin.testbench.By;
-import com.vaadin.testbench.TestBenchElement;
-import com.vaadin.testbench.elementsbase.ServerClass;
-
-@ServerClass("com.vaadin.ui.Grid")
-public class GridElement extends com.vaadin.testbench.elements.GridElement {
-
- /**
- * Gets the element that contains the details of a row.
- *
- * @since 8.0
- * @param rowIndex
- * the index of the row for the details
- * @return the element that contains the details of a row. <code>null</code>
- * if no widget is defined for the detials row
- * @throws NoSuchElementException
- * if the given details row is currently not open
- */
- @Override
- public TestBenchElement getDetails(int rowIndex)
- throws NoSuchElementException {
- return getSubPart("#details[" + rowIndex + "]");
- }
-
- private TestBenchElement getSubPart(String subPartSelector) {
- return (TestBenchElement) findElement(By.vaadin(subPartSelector));
- }
-}
diff --git a/uitest-common/src/main/java/com/vaadin/testbench/customelements/MenuBarElement.java b/uitest-common/src/main/java/com/vaadin/testbench/customelements/MenuBarElement.java
deleted file mode 100644
index 55a0785e3d..0000000000
--- a/uitest-common/src/main/java/com/vaadin/testbench/customelements/MenuBarElement.java
+++ /dev/null
@@ -1,15 +0,0 @@
-package com.vaadin.testbench.customelements;
-
-import com.vaadin.testbench.By;
-import com.vaadin.testbench.elementsbase.ServerClass;
-
-@ServerClass("com.vaadin.ui.MenuBar")
-public class MenuBarElement
- extends com.vaadin.testbench.elements.MenuBarElement {
-
- public void openMenuPath(String... captions) {
- for (String c : captions) {
- findElement(By.vaadin("#" + c)).click();
- }
- }
-}
diff --git a/uitest-common/src/main/java/com/vaadin/testbench/customelements/NativeSelectElement.java b/uitest-common/src/main/java/com/vaadin/testbench/customelements/NativeSelectElement.java
deleted file mode 100644
index a183951a29..0000000000
--- a/uitest-common/src/main/java/com/vaadin/testbench/customelements/NativeSelectElement.java
+++ /dev/null
@@ -1,76 +0,0 @@
-/*
- * Copyright 2000-2016 Vaadin Ltd.
- *
- * Licensed under the Apache License, Version 2.0 (the "License"); you may not
- * use this file except in compliance with the License. You may obtain a copy of
- * the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
- * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
- * License for the specific language governing permissions and limitations under
- * the License.
- */
-package com.vaadin.testbench.customelements;
-
-import java.util.List;
-
-import org.openqa.selenium.support.ui.Select;
-
-import com.vaadin.testbench.By;
-import com.vaadin.testbench.TestBenchElement;
-import com.vaadin.testbench.elements.AbstractSelectElement;
-import com.vaadin.testbench.elementsbase.ServerClass;
-
-@ServerClass("com.vaadin.ui.NativeSelect")
-public class NativeSelectElement extends AbstractSelectElement {
- private Select selectElement;
-
- @Override
- protected void init() {
- super.init();
- selectElement = new Select(findElement(By.tagName("select")));
- }
-
- public List<TestBenchElement> getOptions() {
- return wrapElements(selectElement.getOptions(), getCommandExecutor());
- }
-
- public void selectByText(String text) throws ReadOnlyException {
- if (isReadOnly()) {
- throw new ReadOnlyException();
- }
- selectElement.selectByVisibleText(text);
- waitForVaadin();
- }
-
- /**
- * Clear operation is not supported for Native Select. This operation has no
- * effect on Native Select element.
- */
- @Override
- public void clear() {
- super.clear();
- }
-
- /**
- * 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();
- }
-
- /**
- * Select item of the native select element with the specified value
- *
- * @param chars
- * value of the native select item will be selected
- */
- public void setValue(CharSequence chars) throws ReadOnlyException {
- selectByText((String) chars);
- }
-}
diff --git a/uitest-common/src/main/java/com/vaadin/testbench/customelements/ProgressBarElement.java b/uitest-common/src/main/java/com/vaadin/testbench/customelements/ProgressBarElement.java
deleted file mode 100644
index 78b6ffb4c4..0000000000
--- a/uitest-common/src/main/java/com/vaadin/testbench/customelements/ProgressBarElement.java
+++ /dev/null
@@ -1,39 +0,0 @@
-/*
- * Copyright 2000-2016 Vaadin Ltd.
- *
- * Licensed under the Apache License, Version 2.0 (the "License"); you may not
- * use this file except in compliance with the License. You may obtain a copy of
- * the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
- * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
- * License for the specific language governing permissions and limitations under
- * the License.
- */
-package com.vaadin.testbench.customelements;
-
-import org.openqa.selenium.By;
-import org.openqa.selenium.WebElement;
-
-import com.vaadin.testbench.elementsbase.ServerClass;
-
-@ServerClass("com.vaadin.ui.ProgressBar")
-public class ProgressBarElement
- extends com.vaadin.testbench.elements.ProgressBarElement {
-
- @Override
- public double getValue() {
- WebElement indicator = findElement(
- By.className("v-progressbar-indicator"));
- String width = getStyleAttribute(indicator, "width");
- if (!width.endsWith("%")) {
- return 0;
- }
-
- return Double.parseDouble(width.replace("%", "")) / 100.0;
- }
-
-}
diff --git a/uitest-common/src/main/java/com/vaadin/testbench/customelements/RadioButtonGroupElement.java b/uitest-common/src/main/java/com/vaadin/testbench/customelements/RadioButtonGroupElement.java
deleted file mode 100644
index ce62ddd4be..0000000000
--- a/uitest-common/src/main/java/com/vaadin/testbench/customelements/RadioButtonGroupElement.java
+++ /dev/null
@@ -1,73 +0,0 @@
-/*
- * Copyright 2000-2014 Vaadin Ltd.
- *
- * Licensed under the Apache License, Version 2.0 (the "License"); you may not
- * use this file except in compliance with the License. You may obtain a copy of
- * the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
- * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
- * License for the specific language governing permissions and limitations under
- * the License.
- */
-package com.vaadin.testbench.customelements;
-
-import java.util.ArrayList;
-import java.util.List;
-
-import org.openqa.selenium.WebElement;
-
-import com.vaadin.testbench.By;
-
-/**
- * TestBench element supporting RadioButtonGroup
- *
- * @author Vaadin Ltd
- */
-
-public class RadioButtonGroupElement
- extends com.vaadin.testbench.elements.RadioButtonGroupElement {
- private static org.openqa.selenium.By byButtonSpan = By
- .className("v-select-option");
-
- /**
- * Return list of the selected options in the radiobutton group
- *
- * @return list of the selected options in the radiobutton group
- */
- public List<String> getSelection() {
- List<String> values = new ArrayList<>();
- List<WebElement> options = findElements(byButtonSpan);
- for (WebElement option : options) {
- WebElement checkedItem;
- checkedItem = option.findElement(By.tagName("input"));
- String checked = checkedItem.getAttribute("checked");
- if (checked != null
- && checkedItem.getAttribute("checked").equals("true")) {
- values.add(option.findElement(By.tagName("label")).getText());
- }
- }
- return values;
- }
-
- /**
- * Select option in the radiobutton group with the specified value
- *
- * @param chars
- * value of the option in the radiobutton group which will be
- * selected
- */
- public void selectOption(CharSequence chars) throws ReadOnlyException {
- selectByText((String) chars);
- }
-
- @Override
- public void clear() {
- throw new UnsupportedOperationException(
- "Clear operation is not supported for RadioButtonGroup."
- + " This operation has no effect on the element.");
- }
-}
diff --git a/uitest-common/src/main/java/com/vaadin/testbench/customelements/TableElement.java b/uitest-common/src/main/java/com/vaadin/testbench/customelements/TableElement.java
deleted file mode 100644
index 28432fade9..0000000000
--- a/uitest-common/src/main/java/com/vaadin/testbench/customelements/TableElement.java
+++ /dev/null
@@ -1,24 +0,0 @@
-package com.vaadin.testbench.customelements;
-
-import org.openqa.selenium.By;
-import org.openqa.selenium.WebElement;
-
-import com.vaadin.testbench.elementsbase.ServerClass;
-
-@ServerClass("com.vaadin.ui.Table")
-public class TableElement extends com.vaadin.testbench.elements.TableElement {
- public CollapseMenu openCollapseMenu() {
- getCollapseMenuToggle().click();
- WebElement cm = getDriver()
- .findElement(By.xpath("//*[@id='PID_VAADIN_CM']"));
- return wrapElement(cm, getCommandExecutor()).wrap(CollapseMenu.class);
- }
-
- public static class CollapseMenu extends ContextMenuElement {
- }
-
- public WebElement getCollapseMenuToggle() {
- return findElement(By.className("v-table-column-selector"));
- }
-
-}
diff --git a/uitest-common/src/main/java/com/vaadin/testbench/customelements/WindowElement.java b/uitest-common/src/main/java/com/vaadin/testbench/customelements/WindowElement.java
deleted file mode 100644
index eae6019b96..0000000000
--- a/uitest-common/src/main/java/com/vaadin/testbench/customelements/WindowElement.java
+++ /dev/null
@@ -1,75 +0,0 @@
-package com.vaadin.testbench.customelements;
-
-import org.openqa.selenium.WebElement;
-import org.openqa.selenium.interactions.Actions;
-
-import com.vaadin.testbench.By;
-import com.vaadin.testbench.elementsbase.ServerClass;
-
-/*
- Suggestions for new elemental api for Window
- */
-@ServerClass("com.vaadin.ui.Window")
-public class WindowElement extends com.vaadin.testbench.elements.WindowElement {
-
- private final String restoreBoxClass = "v-window-restorebox";
- private final String maximizeBoxClass = "v-window-maximizebox";
- private final String closeBoxClass = "v-window-closebox";
-
- @Override
- public void restore() {
- if (isMaximized()) {
- getRestoreButton().click();
- } else {
- throw new AssertionError(
- "Window is not maximized, cannot be restored.");
- }
- }
-
- private WebElement getRestoreButton() {
- return findElement(By.className("v-window-restorebox"));
- }
-
- @Override
- public void maximize() {
- if (!isMaximized()) {
- getMaximizeButton().click();
- } else {
- throw new AssertionError(
- "Window is already maximized, cannot maximize.");
- }
- }
-
- private WebElement getMaximizeButton() {
- return findElement(By.className(maximizeBoxClass));
- }
-
- public void move(int xOffset, int yOffset) {
- Actions action = new Actions(getDriver());
- action.moveToElement(
- findElement(org.openqa.selenium.By.className("v-window-wrap")),
- 5, 5);
- action.clickAndHold();
- action.moveByOffset(xOffset, yOffset);
- action.release();
- action.build().perform();
- }
-
- /**
- * @return the caption of the window
- */
- @Override
- public String getCaption() {
- return findElement(By.className("v-window-header")).getText();
- }
-
- private WebElement getCloseButton() {
- return findElement(By.className(closeBoxClass));
- }
-
- @Override
- public void close() {
- getCloseButton().click();
-
- }
-}