aboutsummaryrefslogtreecommitdiffstats
path: root/uitest/src
diff options
context:
space:
mode:
authorBogdan Udrescu <bogdan@vaadin.com>2014-08-07 15:31:07 +0300
committerBogdan Udrescu <bogdan@vaadin.com>2014-08-14 17:04:39 +0300
commit8c4ddbb2837c8966551636cf140bba86c9671d1e (patch)
tree44956315838bcd6a530a7d07edcb483a86fb84a7 /uitest/src
parentea8374649ba8b3b2d38a49a73eda205faf2f0fe9 (diff)
downloadvaadin-framework-8c4ddbb2837c8966551636cf140bba86c9671d1e.tar.gz
vaadin-framework-8c4ddbb2837c8966551636cf140bba86c9671d1e.zip
TabSheet focus/blur events fixed (#14304)
The blur and focus events should be linked with the TabSheet component as a whole. Any click inside the TabSheet should trigger one single focus and any leave the blur. Change-Id: Id24a2fab12aafe6f7aa3a44635e5b9e935a1cfe1
Diffstat (limited to 'uitest/src')
-rw-r--r--uitest/src/com/vaadin/tests/components/tabsheet/TabKeyboardNavigation.html241
-rw-r--r--uitest/src/com/vaadin/tests/components/tabsheet/TabKeyboardNavigation.java32
-rw-r--r--uitest/src/com/vaadin/tests/components/tabsheet/TabKeyboardNavigationTest.java188
3 files changed, 213 insertions, 248 deletions
diff --git a/uitest/src/com/vaadin/tests/components/tabsheet/TabKeyboardNavigation.html b/uitest/src/com/vaadin/tests/components/tabsheet/TabKeyboardNavigation.html
deleted file mode 100644
index 825988173a..0000000000
--- a/uitest/src/com/vaadin/tests/components/tabsheet/TabKeyboardNavigation.html
+++ /dev/null
@@ -1,241 +0,0 @@
-<?xml version="1.0" encoding="UTF-8"?>
-<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
-<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">
-<head profile="http://selenium-ide.openqa.org/profiles/test-case">
-<meta http-equiv="Content-Type" content="text/html; charset=UTF-8" />
-<title>TabKeyboardNavigation</title>
-</head>
-<body>
-<table cellpadding="1" cellspacing="1" border="1">
-<thead>
-<tr><td rowspan="1" colspan="3">TabKeyboardNavigation</td></tr>
-</thead><tbody>
-<tr>
- <td>open</td>
- <td>/run/TabKeyboardNavigation?restartApplication</td>
- <td></td>
-</tr>
-<tr>
- <td>mouseClick</td>
- <td>vaadin=runTabKeyboardNavigation::/VVerticalLayout[0]/ChildComponentContainer[1]/VVerticalLayout[0]/ChildComponentContainer[4]/VTabsheet[0]/domChild[0]/domChild[0]/domChild[0]/domChild[0]/domChild[0]/domChild[0]/domChild[0]/domChild[0]</td>
- <td>9,8</td>
-</tr>
-<tr>
- <td>pressSpecialKey</td>
- <td>vaadin=runTabKeyboardNavigation::/VVerticalLayout[0]/ChildComponentContainer[1]/VVerticalLayout[0]/ChildComponentContainer[4]/VTabsheet[0]/domChild[0]/domChild[0]/domChild[0]/domChild[0]/domChild[0]</td>
- <td>right</td>
-</tr>
-<tr>
- <td>pause</td>
- <td>1000</td>
- <td>1000</td>
-</tr>
-<tr>
- <td>assertText</td>
- <td>vaadin=runTabKeyboardNavigation::/VVerticalLayout[0]/ChildComponentContainer[1]/VVerticalLayout[0]/ChildComponentContainer[4]/VTabsheet[0]/VTabsheetPanel[0]/VVerticalLayout[1]/ChildComponentContainer[0]/VLabel[0]</td>
- <td>Tab 1</td>
-</tr>
-<tr>
- <td>pressSpecialKey</td>
- <td>vaadin=runTabKeyboardNavigation::/VVerticalLayout[0]/ChildComponentContainer[1]/VVerticalLayout[0]/ChildComponentContainer[4]/VTabsheet[0]/domChild[0]/domChild[0]/domChild[0]/domChild[0]/domChild[0]</td>
- <td>space</td>
-</tr>
-<tr>
- <td>assertText</td>
- <td>vaadin=runTabKeyboardNavigation::/VVerticalLayout[0]/ChildComponentContainer[1]/VVerticalLayout[0]/ChildComponentContainer[4]/VTabsheet[0]/VTabsheetPanel[0]/VVerticalLayout[1]/ChildComponentContainer[0]/VLabel[0]</td>
- <td>Tab 2</td>
-</tr>
-<tr>
- <td>screenCapture</td>
- <td></td>
- <td>tab2</td>
-</tr>
-<tr>
- <td>pressSpecialKey</td>
- <td>vaadin=runTabKeyboardNavigation::/VVerticalLayout[0]/ChildComponentContainer[1]/VVerticalLayout[0]/ChildComponentContainer[4]/VTabsheet[0]/domChild[0]/domChild[0]/domChild[0]/domChild[0]/domChild[1]</td>
- <td>right</td>
-</tr>
-<tr>
- <td>pressSpecialKey</td>
- <td>vaadin=runTabKeyboardNavigation::/VVerticalLayout[0]/ChildComponentContainer[1]/VVerticalLayout[0]/ChildComponentContainer[4]/VTabsheet[0]/domChild[0]/domChild[0]/domChild[0]/domChild[0]/domChild[2]</td>
- <td>right</td>
-</tr>
-<tr>
- <td>pause</td>
- <td>1000</td>
- <td>1000</td>
-</tr>
-<tr>
- <td>assertText</td>
- <td>vaadin=runTabKeyboardNavigation::/VVerticalLayout[0]/ChildComponentContainer[1]/VVerticalLayout[0]/ChildComponentContainer[4]/VTabsheet[0]/VTabsheetPanel[0]/VVerticalLayout[3]/ChildComponentContainer[0]/VLabel[0]</td>
- <td>Tab 2</td>
-</tr>
-<tr>
- <td>pressSpecialKey</td>
- <td>vaadin=runTabKeyboardNavigation::/VVerticalLayout[0]/ChildComponentContainer[1]/VVerticalLayout[0]/ChildComponentContainer[4]/VTabsheet[0]/domChild[0]/domChild[0]/domChild[0]/domChild[0]/domChild[2]</td>
- <td>space</td>
-</tr>
-<tr>
- <td>assertText</td>
- <td>vaadin=runTabKeyboardNavigation::/VVerticalLayout[0]/ChildComponentContainer[1]/VVerticalLayout[0]/ChildComponentContainer[4]/VTabsheet[0]/VTabsheetPanel[0]/VVerticalLayout[3]/ChildComponentContainer[0]/VLabel[0]</td>
- <td>Tab 5</td>
-</tr>
-<tr>
- <td>screenCapture</td>
- <td></td>
- <td>skip-disabled-to-tab5</td>
-</tr>
-<tr>
- <td>click</td>
- <td>vaadin=runTabKeyboardNavigation::/VVerticalLayout[0]/ChildComponentContainer[1]/VVerticalLayout[0]/ChildComponentContainer[0]/VButton[0]/domChild[0]/domChild[0]</td>
- <td></td>
-</tr>
-<tr>
- <td>pressSpecialKey</td>
- <td>vaadin=runTabKeyboardNavigation::/VVerticalLayout[0]/ChildComponentContainer[1]/VVerticalLayout[0]/ChildComponentContainer[4]/VTabsheet[0]/domChild[0]/domChild[0]/domChild[0]/domChild[0]/domChild[0]</td>
- <td>right</td>
-</tr>
-<tr>
- <td>pause</td>
- <td>1000</td>
- <td>1000</td>
-</tr>
-<tr>
- <td>assertText</td>
- <td>vaadin=runTabKeyboardNavigation::/VVerticalLayout[0]/ChildComponentContainer[1]/VVerticalLayout[0]/ChildComponentContainer[4]/VTabsheet[0]/VTabsheetPanel[0]/VVerticalLayout[4]/ChildComponentContainer[0]/VLabel[0]</td>
- <td>Tab 5</td>
-</tr>
-<tr>
- <td>pressSpecialKey</td>
- <td>vaadin=runTabKeyboardNavigation::/VVerticalLayout[0]/ChildComponentContainer[1]/VVerticalLayout[0]/ChildComponentContainer[4]/VTabsheet[0]/domChild[0]/domChild[0]/domChild[0]/domChild[0]/domChild[0]</td>
- <td>space</td>
-</tr>
-<tr>
- <td>assertText</td>
- <td>vaadin=runTabKeyboardNavigation::/VVerticalLayout[0]/ChildComponentContainer[1]/VVerticalLayout[0]/ChildComponentContainer[4]/VTabsheet[0]/VTabsheetPanel[0]/VVerticalLayout[4]/ChildComponentContainer[0]/VLabel[0]</td>
- <td>Tab 6</td>
-</tr>
-<tr>
- <td>click</td>
- <td>vaadin=runTabKeyboardNavigation::/VVerticalLayout[0]/ChildComponentContainer[1]/VVerticalLayout[0]/ChildComponentContainer[0]/VButton[0]/domChild[0]/domChild[0]</td>
- <td></td>
-</tr>
-<tr>
- <td>click</td>
- <td>vaadin=runTabKeyboardNavigation::/VVerticalLayout[0]/ChildComponentContainer[1]/VVerticalLayout[0]/ChildComponentContainer[0]/VButton[0]/domChild[0]/domChild[0]</td>
- <td></td>
-</tr>
-<tr>
- <td>click</td>
- <td>vaadin=runTabKeyboardNavigation::/VVerticalLayout[0]/ChildComponentContainer[1]/VVerticalLayout[0]/ChildComponentContainer[0]/VButton[0]/domChild[0]/domChild[0]</td>
- <td></td>
-</tr>
-<tr>
- <td>click</td>
- <td>vaadin=runTabKeyboardNavigation::/VVerticalLayout[0]/ChildComponentContainer[1]/VVerticalLayout[0]/ChildComponentContainer[0]/VButton[0]/domChild[0]/domChild[0]</td>
- <td></td>
-</tr>
-<tr>
- <td>click</td>
- <td>vaadin=runTabKeyboardNavigation::/VVerticalLayout[0]/ChildComponentContainer[1]/VVerticalLayout[0]/ChildComponentContainer[0]/VButton[0]/domChild[0]/domChild[0]</td>
- <td></td>
-</tr>
-<tr>
- <td>click</td>
- <td>vaadin=runTabKeyboardNavigation::/VVerticalLayout[0]/ChildComponentContainer[1]/VVerticalLayout[0]/ChildComponentContainer[0]/VButton[0]/domChild[0]/domChild[0]</td>
- <td></td>
-</tr>
-<tr>
- <td>mouseClick</td>
- <td>vaadin=runTabKeyboardNavigation::/VVerticalLayout[0]/ChildComponentContainer[1]/VVerticalLayout[0]/ChildComponentContainer[4]/VTabsheet[0]/domChild[0]/domChild[0]/domChild[0]/domChild[0]/domChild[8]/domChild[0]/domChild[0]/domChild[0]</td>
- <td>18,10</td>
-</tr>
-<tr>
- <td>pressSpecialKey</td>
- <td>vaadin=runTabKeyboardNavigation::/VVerticalLayout[0]/ChildComponentContainer[1]/VVerticalLayout[0]/ChildComponentContainer[4]/VTabsheet[0]/domChild[0]/domChild[0]/domChild[0]/domChild[0]/domChild[8]</td>
- <td>right</td>
-</tr>
-<tr>
- <td>pressSpecialKey</td>
- <td>vaadin=runTabKeyboardNavigation::/VVerticalLayout[0]/ChildComponentContainer[1]/VVerticalLayout[0]/ChildComponentContainer[4]/VTabsheet[0]/domChild[0]/domChild[0]/domChild[0]/domChild[0]/domChild[9]</td>
- <td>right</td>
-</tr>
-<tr>
- <td>pressSpecialKey</td>
- <td>vaadin=runTabKeyboardNavigation::/VVerticalLayout[0]/ChildComponentContainer[1]/VVerticalLayout[0]/ChildComponentContainer[4]/VTabsheet[0]/domChild[0]/domChild[0]/domChild[0]/domChild[0]/domChild[10]</td>
- <td>right</td>
-</tr>
-<tr>
- <td>pause</td>
- <td>1000</td>
- <td>1000</td>
-</tr>
-<tr>
- <td>assertText</td>
- <td>vaadin=runTabKeyboardNavigation::/VVerticalLayout[0]/ChildComponentContainer[1]/VVerticalLayout[0]/ChildComponentContainer[4]/VTabsheet[0]/VTabsheetPanel[0]/VVerticalLayout[8]/ChildComponentContainer[0]/VLabel[0]</td>
- <td>Tab 9</td>
-</tr>
-<tr>
- <td>pressSpecialKey</td>
- <td>vaadin=runTabKeyboardNavigation::/VVerticalLayout[0]/ChildComponentContainer[1]/VVerticalLayout[0]/ChildComponentContainer[4]/VTabsheet[0]/domChild[0]/domChild[0]/domChild[0]/domChild[0]/domChild[10]</td>
- <td>space</td>
-</tr>
-<tr>
- <td>assertText</td>
- <td>vaadin=runTabKeyboardNavigation::/VVerticalLayout[0]/ChildComponentContainer[1]/VVerticalLayout[0]/ChildComponentContainer[4]/VTabsheet[0]/VTabsheetPanel[0]/VVerticalLayout[8]/ChildComponentContainer[0]/VLabel[0]</td>
- <td>Tab 12</td>
-</tr>
-<tr>
- <td>screenCapture</td>
- <td></td>
- <td>scrolled-right-to-tab-12</td>
-</tr>
-<tr>
- <td>mouseClick</td>
- <td>vaadin=runTabKeyboardNavigation::/VVerticalLayout[0]/ChildComponentContainer[1]/VVerticalLayout[0]/ChildComponentContainer[4]/VTabsheet[0]/domChild[0]/domChild[0]/domChild[0]/domChild[0]/domChild[4]/domChild[0]/domChild[0]/domChild[0]</td>
- <td>11,2</td>
-</tr>
-<tr>
- <td>pressSpecialKey</td>
- <td>vaadin=runTabKeyboardNavigation::/VVerticalLayout[0]/ChildComponentContainer[1]/VVerticalLayout[0]/ChildComponentContainer[4]/VTabsheet[0]/domChild[0]/domChild[0]/domChild[0]/domChild[0]/domChild[4]</td>
- <td>left</td>
-</tr>
-<tr>
- <td>pressSpecialKey</td>
- <td>vaadin=runTabKeyboardNavigation::/VVerticalLayout[0]/ChildComponentContainer[1]/VVerticalLayout[0]/ChildComponentContainer[4]/VTabsheet[0]/domChild[0]/domChild[0]/domChild[0]/domChild[0]/domChild[2]</td>
- <td>left</td>
-</tr>
-<tr>
- <td>pressSpecialKey</td>
- <td>vaadin=runTabKeyboardNavigation::/VVerticalLayout[0]/ChildComponentContainer[1]/VVerticalLayout[0]/ChildComponentContainer[4]/VTabsheet[0]/domChild[0]/domChild[0]/domChild[0]/domChild[0]/domChild[1]</td>
- <td>left</td>
-</tr>
-<tr>
- <td>pause</td>
- <td>1000</td>
- <td>1000</td>
-</tr>
-<tr>
- <td>assertText</td>
- <td>vaadin=runTabKeyboardNavigation::/VVerticalLayout[0]/ChildComponentContainer[1]/VVerticalLayout[0]/ChildComponentContainer[4]/VTabsheet[0]/VTabsheetPanel[0]/VVerticalLayout[0]/ChildComponentContainer[0]/VLabel[0]</td>
- <td>Tab 5</td>
-</tr>
-<tr>
- <td>pressSpecialKey</td>
- <td>vaadin=runTabKeyboardNavigation::/VVerticalLayout[0]/ChildComponentContainer[1]/VVerticalLayout[0]/ChildComponentContainer[4]/VTabsheet[0]/domChild[0]/domChild[0]/domChild[0]/domChild[0]/domChild[1]</td>
- <td>space</td>
-</tr>
-<tr>
- <td>assertText</td>
- <td>vaadin=runTabKeyboardNavigation::/VVerticalLayout[0]/ChildComponentContainer[1]/VVerticalLayout[0]/ChildComponentContainer[4]/VTabsheet[0]/VTabsheetPanel[0]/VVerticalLayout[0]/ChildComponentContainer[0]/VLabel[0]</td>
- <td>Tab 1</td>
-</tr>
-<tr>
- <td>screenCapture</td>
- <td></td>
- <td>scrolled-left-to-tab-1</td>
-</tr>
-
-</tbody></table>
-</body>
-</html>
diff --git a/uitest/src/com/vaadin/tests/components/tabsheet/TabKeyboardNavigation.java b/uitest/src/com/vaadin/tests/components/tabsheet/TabKeyboardNavigation.java
index ba737f1df8..620f04fe60 100644
--- a/uitest/src/com/vaadin/tests/components/tabsheet/TabKeyboardNavigation.java
+++ b/uitest/src/com/vaadin/tests/components/tabsheet/TabKeyboardNavigation.java
@@ -6,7 +6,8 @@ import com.vaadin.event.FieldEvents.BlurEvent;
import com.vaadin.event.FieldEvents.BlurListener;
import com.vaadin.event.FieldEvents.FocusEvent;
import com.vaadin.event.FieldEvents.FocusListener;
-import com.vaadin.tests.components.TestBase;
+import com.vaadin.server.VaadinRequest;
+import com.vaadin.tests.components.AbstractTestUI;
import com.vaadin.tests.util.Log;
import com.vaadin.ui.Button;
import com.vaadin.ui.Button.ClickEvent;
@@ -19,7 +20,16 @@ import com.vaadin.ui.TabSheet.Tab;
import com.vaadin.ui.TextField;
import com.vaadin.ui.VerticalLayout;
-public class TabKeyboardNavigation extends TestBase {
+/**
+ * Test if the click and key tab selection in a tabsheet generate the correct
+ * focus/blur events.
+ *
+ * The solution was broken in ticket (#14304)
+ *
+ * @since
+ * @author Vaadin Ltd
+ */
+public class TabKeyboardNavigation extends AbstractTestUI {
int index = 1;
ArrayList<Component> tabs = new ArrayList<Component>();
@@ -27,18 +37,18 @@ public class TabKeyboardNavigation extends TestBase {
Log focusblur = new Log(10);
@Override
- protected void setup() {
+ protected void setup(VaadinRequest request) {
ts.setWidth("500px");
ts.setHeight("500px");
- ts.addListener(new FocusListener() {
+ ts.addFocusListener(new FocusListener() {
@Override
public void focus(FocusEvent event) {
focusblur.log("Tabsheet focused!");
}
});
- ts.addListener(new BlurListener() {
+ ts.addBlurListener(new BlurListener() {
@Override
public void blur(BlurEvent event) {
focusblur.log("Tabsheet blurred!");
@@ -74,7 +84,7 @@ public class TabKeyboardNavigation extends TestBase {
}
@Override
- protected String getDescription() {
+ protected String getTestDescription() {
return "The tab bar should be focusable and arrow keys should switch tabs. The del key should close a tab if closable.";
}
@@ -83,10 +93,18 @@ public class TabKeyboardNavigation extends TestBase {
return 5100;
}
+ public final static String LABEL_ID = "sheetLabel";
+
+ public final static String labelID(int index) {
+ return LABEL_ID + index;
+ }
+
private Tab addTab() {
Layout content = new VerticalLayout();
tabs.add(content);
- content.addComponent(new Label("Tab " + index));
+ Label label = new Label("Tab " + index);
+ label.setId(labelID(index));
+ content.addComponent(label);
content.addComponent(new TextField());
Tab tab = ts.addTab(content, "Tab " + index, null);
if (index == 2) {
diff --git a/uitest/src/com/vaadin/tests/components/tabsheet/TabKeyboardNavigationTest.java b/uitest/src/com/vaadin/tests/components/tabsheet/TabKeyboardNavigationTest.java
new file mode 100644
index 0000000000..65307f9492
--- /dev/null
+++ b/uitest/src/com/vaadin/tests/components/tabsheet/TabKeyboardNavigationTest.java
@@ -0,0 +1,188 @@
+/*
+ * 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.tests.components.tabsheet;
+
+import java.io.IOException;
+
+import org.junit.Assert;
+import org.junit.Test;
+import org.openqa.selenium.By;
+import org.openqa.selenium.Keys;
+import org.openqa.selenium.WebElement;
+
+import com.vaadin.testbench.TestBenchElement;
+import com.vaadin.tests.tb3.MultiBrowserTest;
+
+/**
+ * Add TB3 test as the TB2 one failed on keyboard events.
+ *
+ * @since
+ * @author Vaadin Ltd
+ */
+public class TabKeyboardNavigationTest extends MultiBrowserTest {
+
+ @Test
+ public void testFocus() throws InterruptedException, IOException {
+ openTestURL();
+
+ click(1);
+ sendKeys(1, Keys.ARROW_RIGHT);
+
+ assertSheet(1);
+ sendKeys(2, Keys.SPACE);
+ assertSheet(2);
+ compareScreen("tab2");
+
+ sendKeys(2, Keys.ARROW_RIGHT);
+ sendKeys(3, Keys.ARROW_RIGHT);
+ assertSheet(2);
+
+ sendKeys(5, Keys.SPACE);
+ assertSheet(5);
+ compareScreen("skip-disabled-to-tab5");
+
+ TestBenchElement addTabButton = (TestBenchElement) getDriver()
+ .findElements(By.className("v-button")).get(0);
+
+ click(addTabButton);
+
+ click(5);
+ sendKeys(5, Keys.ARROW_RIGHT);
+ assertSheet(5);
+
+ sendKeys(6, Keys.SPACE);
+ assertSheet(6);
+
+ click(addTabButton);
+ click(addTabButton);
+ click(addTabButton);
+ click(addTabButton);
+ click(addTabButton);
+ click(addTabButton);
+
+ click(8);
+ compareScreen("click-tab-8");
+
+ sendKeys(8, Keys.ARROW_RIGHT);
+ sendKeys(9, Keys.SPACE);
+ click(9);
+ compareScreen("tab-9");
+
+ sendKeys(9, Keys.ARROW_RIGHT);
+ Thread.sleep(DELAY);
+
+ sendKeys(10, Keys.ARROW_RIGHT);
+
+ // Here PhantomJS used to fail. Or when accessing tab2. The fix was to
+ // call the elem.click(x, y) using the (x, y) position instead of the
+ // elem.click() without any arguments.
+ sendKeys(11, Keys.ARROW_RIGHT);
+
+ assertSheet(9);
+ sendKeys(12, Keys.SPACE);
+ assertSheet(12);
+ compareScreen("scrolled-right-to-tab-12");
+
+ click(5);
+
+ sendKeys(5, Keys.ARROW_LEFT);
+
+ // Here IE8 used to fail. A hidden <div> in IE8 would have the bounds of
+ // it's parent, and when trying to see in which direction to scroll
+ // (left or right) to make the key selected tab visible, the
+ // VTabSheet.scrollIntoView(Tab) used to check first whether the tab
+ // isClipped. On IE8 this will always return true for both hidden tabs
+ // on the left and clipped tabs on the right. So instead of going to
+ // left, it'll search all the way to the right.
+ sendKeys(3, Keys.ARROW_LEFT);
+ sendKeys(2, Keys.ARROW_LEFT);
+ assertSheet(5);
+
+ sendKeys(1, Keys.SPACE);
+ assertSheet(1);
+ compareScreen("scrolled-left-to-tab-1");
+ }
+
+ /*
+ * Press key on the element.
+ */
+ private void sendKeys(int tabIndex, Keys key) throws InterruptedException {
+ sendKeys(tab(tabIndex), key);
+ }
+
+ /*
+ * Press key on the element.
+ */
+ private void sendKeys(TestBenchElement element, Keys key)
+ throws InterruptedException {
+
+ element.sendKeys(key);
+ if (DELAY > 0) {
+ sleep(DELAY);
+ }
+ }
+
+ /*
+ * Click on the element.
+ */
+ private void click(int tabIndex) throws InterruptedException {
+ click(tab(tabIndex));
+ }
+
+ /*
+ * Click on the element.
+ */
+ private void click(TestBenchElement element) throws InterruptedException {
+
+ element.click(10, 10);
+ if (DELAY > 0) {
+ sleep(DELAY);
+ }
+ }
+
+ /*
+ * Delay for PhantomJS.
+ */
+ private final static int DELAY = 10;
+
+ private void assertSheet(int index) {
+ String labelCaption = "Tab " + index;
+
+ By id = By.id(TabKeyboardNavigation.labelID(index));
+ WebElement labelElement = getDriver().findElement(id);
+
+ waitForElementPresent(id);
+
+ Assert.assertEquals(labelCaption, labelCaption, labelElement.getText());
+ }
+
+ /*
+ * Provide the tab at specified index.
+ */
+ private TestBenchElement tab(int index) {
+ By by = By.className("v-tabsheet-tabitemcell");
+
+ TestBenchElement element = (TestBenchElement) getDriver().findElements(
+ by).get(index - 1);
+
+ String expected = "Tab " + index;
+ Assert.assertEquals(expected,
+ element.getText().substring(0, expected.length()));
+
+ return element;
+ }
+
+}