blob: 81a917505f671ac236c7dbac3be5b450b7bd2fc9 (
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
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
|
package com.vaadin.tests.components.menubar;
import static com.vaadin.tests.components.menubar.MenuBarsWithNesting.itemNames;
import static com.vaadin.tests.components.menubar.MenuBarsWithNesting.nestedItemnames;
import org.junit.Before;
import org.junit.Test;
import org.openqa.selenium.WebElement;
import org.openqa.selenium.support.ui.ExpectedConditions;
import com.vaadin.testbench.By;
import com.vaadin.testbench.elements.LabelElement;
import com.vaadin.testbench.elements.MenuBarElement;
import com.vaadin.tests.tb3.MultiBrowserTest;
/**
* This class tests the method VMenuBar.getSubPartElement(String) by using
* Vaadin locators for finding the items of a MenuBar.
*
* @author Vaadin Ltd
*/
public class MenuBarsWithNestingTest extends MultiBrowserTest {
private MenuBarElement firstMenuBar, secondMenuBar;
private LabelElement label;
@Before
public void init() {
openTestURL();
firstMenuBar = $(MenuBarElement.class).first();
secondMenuBar = $(MenuBarElement.class).get(1);
label = $(LabelElement.class).get(1);
}
@Test
public void testMenuWithoutIcons() {
WebElement fileMenu = firstMenuBar.findElement(By.vaadin("#File"));
fileMenu.click();
WebElement exportMenu = fileMenu.findElement(By.vaadin("#Export.."));
exportMenu.click();
waitUntil(ExpectedConditions.visibilityOfElementLocated(
By.xpath(".//*[text() = 'As PDF...']")));
}
@Test
public void testMenuWithIcons() throws InterruptedException {
// There is a separate test for the last item of the second menu.
for (int i = 0; i < itemNames.length - 1; i++) {
String itemName = itemNames[i];
secondMenuBar.findElement(By.vaadin("#" + itemName)).click();
waitUntil(ExpectedConditions.textToBePresentInElement(
label.getWrappedElement(), itemName));
}
}
@Test
public void testNestedMenuWithIcons() throws InterruptedException {
String selection = itemNames[itemNames.length - 1];
for (String itemName : nestedItemnames) {
WebElement lastMenuItem = secondMenuBar
.findElement(By.vaadin("#" + selection));
lastMenuItem.click();
lastMenuItem.findElement(By.vaadin("#" + itemName)).click();
waitUntil(ExpectedConditions.textToBePresentInElement(
label.getWrappedElement(), itemName));
}
}
}
|