blob: 61d22ae647004867c0c199c3fa90bb2b3dea1e74 (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
|
package com.vaadin.tests.focusable;
import static org.junit.Assert.assertEquals;
import static org.junit.Assert.assertTrue;
import org.junit.Before;
import org.junit.Test;
import org.openqa.selenium.WebElement;
import com.vaadin.tests.tb3.MultiBrowserTest;
public abstract class AbstractFocusableComponentTest extends MultiBrowserTest {
@Before
public void setUp() {
openTestURL();
}
@Test
public void testProgrammaticFocus() {
selectMenuPath("Component", "State", "Set focus");
assertTrue("Component should be focused", isFocused());
}
@Test
public void testTabIndex() {
assertEquals("0", getTabIndex());
selectMenuPath("Component", "State", "Tab index", "-1");
assertEquals("-1", getTabIndex());
selectMenuPath("Component", "State", "Tab index", "10");
assertEquals("10", getTabIndex());
}
protected String getTabIndex() {
return getFocusElement().getAttribute("tabindex");
}
protected boolean isFocused() {
return getFocusElement().equals(getDriver().switchTo().activeElement());
}
protected abstract WebElement getFocusElement();
}
|