import com.vaadin.testbench.TestBenchElement;
import com.vaadin.testbench.elementsbase.AbstractElement;
import com.vaadin.testbench.elementsbase.ServerClass;
+import com.vaadin.testbench.parallel.BrowserUtil;
@ServerClass("com.vaadin.ui.TabSheet")
public class TabSheetElement extends AbstractComponentContainerElement {
}
// If neither text nor icon caption was found, click at a position that
// is unlikely to close the tab.
- ((TestBenchElement) tabCell).click(-5, 0);
+ if (BrowserUtil.isIE(getCapabilities())) {
+ // old default, offset calculated from top left
+ ((TestBenchElement) tabCell).click(10, 10);
+ } else {
+ // w3c compliant, offset calculated from middle
+ ((TestBenchElement) tabCell).click(-5, 0);
+ }
}
/**
public void testValo() throws IOException, InterruptedException {
StringBuilder exceptions = new StringBuilder();
boolean failed = false;
- // upper limit is determined by the amount of tabs (wider than for
- // reindeer), lower end by limits set by Selenium version
- for (int i = 1550; i >= 650; i = i - 50) {
+ // 1550 would be better for the amount of tabs (wider than for
+ // reindeer), but IE11 can't adjust that far
+ for (int i = 1500; i >= 650; i = i - 50) {
try {
testResize(i);
} catch (Exception e) {
import static com.vaadin.tests.components.window.BackspaceKeyWithModalOpened.BTN_OPEN_MODAL_ID;
import static org.junit.Assert.assertEquals;
import static org.openqa.selenium.Keys.BACK_SPACE;
-import static org.openqa.selenium.Keys.TAB;
import org.junit.Before;
-import org.junit.Ignore;
import org.junit.Test;
import org.openqa.selenium.WebElement;
-import org.openqa.selenium.interactions.Actions;
import com.vaadin.testbench.By;
import com.vaadin.testbench.elements.ButtonElement;
checkButtonsCount();
}
- /**
- * Tests that backspace action outside textfield is prevented
- */
- @Test
- public void testWithFocusOnModal() throws Exception {
- // Try to send back actions to the browser.
- new Actions(getDriver()).sendKeys(BACK_SPACE).perform();
-
- checkButtonsCount();
- }
-
- /**
- * Tests that backspace action in the bottom component is prevented.
- *
- * Ignored because the fix to #8855 stops the top and bottom components from
- * functioning as focus traps. Meanwhile, navigation with Backspace is not
- * anymore supported by reasonable browsers.
- */
- @Test
- @Ignore
- public void testWithFocusOnBottom() throws Exception {
- TextFieldElement textField = getTextField();
-
- // tab in last field set focus on bottom component
- textField.sendKeys(TAB);
-
- // Try to send back actions to the browser.
- new Actions(getDriver()).sendKeys(BACK_SPACE).perform();
-
- checkButtonsCount();
- }
-
private TextFieldElement getTextField() {
return $(TextFieldElement.class).first();
}
package com.vaadin.tests.components.window;
+import static org.junit.Assert.assertFalse;
import static org.junit.Assert.assertTrue;
-import java.util.List;
-
import org.junit.Test;
import org.openqa.selenium.Keys;
import org.openqa.selenium.WebElement;
-import org.openqa.selenium.remote.DesiredCapabilities;
+import org.openqa.selenium.interactions.Actions;
import com.vaadin.testbench.By;
import com.vaadin.testbench.elements.TextFieldElement;
-import com.vaadin.testbench.parallel.Browser;
+import com.vaadin.tests.tb3.MultiBrowserTest;
/**
* Tests that a modal window is focused on creation and that on closing a window
*
* @author Vaadin Ltd
*/
-public class ModalWindowRefocusTest extends ModalWindowFocusTest {
-
- @Override
- public List<DesiredCapabilities> getBrowsersToTest() {
- // Chrome doesn't support clicking on the modality curtain
- return getBrowserCapabilities(Browser.IE11, Browser.EDGE,
- Browser.FIREFOX);
- }
+public class ModalWindowRefocusTest extends MultiBrowserTest {
@Override
protected Class<?> getUIClass() {
*/
@Test
public void testFocusOutsideModal() {
+ openTestURL();
waitForElementPresent(By.id("modalWindowButton"));
WebElement button = findElement(By.id("modalWindowButton"));
button.click();
+
waitForElementPresent(By.id("focusfield"));
+ TextFieldElement tfe = $(TextFieldElement.class).id("focusfield");
+ assertFalse("First TextField should not have focus",
+ "this has been focused".equals(tfe.getValue()));
+
WebElement curtain = findElement(
org.openqa.selenium.By.className("v-window-modalitycurtain"));
testBenchElement(curtain).click(getXOffset(curtain, 20),
pressKeyAndWait(Keys.TAB);
pressKeyAndWait(Keys.TAB);
- TextFieldElement tfe = $(TextFieldElement.class).id("focusfield");
assertTrue("First TextField should have received focus",
"this has been focused".equals(tfe.getValue()));
}
+ protected void pressKeyAndWait(Keys key) {
+ new Actions(driver).sendKeys(key).build().perform();
+ sleep(100);
+ }
+
}