blob: 9d7fb618adda466e64af742aed8c368aef5dbd85 (
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
68
69
70
71
72
73
74
75
|
package com.vaadin.tests.actions;
import static org.hamcrest.CoreMatchers.endsWith;
import static org.hamcrest.CoreMatchers.not;
import static org.junit.Assert.assertThat;
import java.util.List;
import org.junit.Before;
import org.junit.Test;
import org.openqa.selenium.WebElement;
import org.openqa.selenium.interactions.Actions;
import org.openqa.selenium.remote.DesiredCapabilities;
import com.vaadin.testbench.By;
import com.vaadin.testbench.elements.TableElement;
import com.vaadin.testbench.parallel.BrowserUtil;
import com.vaadin.tests.tb3.MultiBrowserTest;
/**
* @author Vaadin Ltd
*/
public class ActionsOnDetachedComponentsTest extends MultiBrowserTest {
@Before
public void init() {
openTestURL();
if (BrowserUtil.isFirefox(getDesiredCapabilities())) {
// focus the page to make shortcuts go to the right place
getDriver().findElement(By.className("v-app")).click();
}
}
@Override
public List<DesiredCapabilities> getBrowsersToTest() {
return getBrowsersSupportingContextMenu();
}
@Test
public void shortcutActionOnDetachedComponentShouldNotBeHandled()
throws InterruptedException {
Actions k = new Actions(driver);
k.sendKeys("a").perform();
k.sendKeys("a").perform();
sleep(500);
assertElementNotPresent(By.id("layer-A"));
assertElementPresent(By.id("layer-B"));
assertThat(getLogRow(0), endsWith("btn-A"));
assertThat(getLogRow(1), not(endsWith("btn-B")));
}
@Test
public void actionOnDetachedComponentShouldNotBeHandled()
throws InterruptedException {
TableElement table = $(TableElement.class).first();
table.getRow(0).contextClick();
// Find the opened menu
WebElement menu = findElement(By.className("v-contextmenu"));
WebElement menuitem = menu
.findElement(By.xpath("//*[text() = 'Table action']"));
Actions doubleClick = new Actions(getDriver());
doubleClick.doubleClick(menuitem).build().perform();
assertElementNotPresent(By.id("layer-A"));
assertElementPresent(By.id("layer-B"));
assertThat(getLogRow(0), endsWith("tableAction"));
assertThat(getLogRow(1), not(endsWith("tableAction")));
}
}
|