Browse Source

Fix TabSheetElement clicks for IE, test tweaks. (#12291)

- Backspace navigation hasn't worked in years thanks to new browser
standards, removed related tests. Left a test for regular backspace use
within a modal window.
- Enabled a modal window test for Chrome since it seems to be working
now, removed extending of another test class to avoid running the tests
twice without any configuration changes.
- Adjusted browser width limitation.
- Added screenshots.
tags/8.14.0.alpha1
Anna Koskinen 3 years ago
parent
commit
4cb4f2d602
No account linked to committer's email address

+ 8
- 1
testbench-api/src/main/java/com/vaadin/testbench/elements/TabSheetElement.java View File

@@ -26,6 +26,7 @@ import com.vaadin.testbench.TestBench;
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 {
@@ -122,7 +123,13 @@ 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);
}
}

/**

BIN
uitest/reference-screenshots/firefox/GridLayoutRegErrorTest-LayoutRegError_ANY_Firefox__RegError-Scrolled.png View File


BIN
uitest/reference-screenshots/firefox/VLayoutRegErrorTest-LayoutRegError_ANY_Firefox__RegError-Scrolled.png View File


+ 3
- 3
uitest/src/test/java/com/vaadin/tests/components/tabsheet/ScrolledTabSheetResizeTest.java View File

@@ -63,9 +63,9 @@ public class ScrolledTabSheetResizeTest extends MultiBrowserTest {
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) {

+ 0
- 35
uitest/src/test/java/com/vaadin/tests/components/window/BackspaceKeyWithModalOpenedTest.java View File

@@ -4,13 +4,10 @@ import static com.vaadin.tests.components.window.BackspaceKeyWithModalOpened.BTN
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;
@@ -34,38 +31,6 @@ public class BackspaceKeyWithModalOpenedTest extends MultiBrowserTest {
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();
}

+ 15
- 13
uitest/src/test/java/com/vaadin/tests/components/window/ModalWindowRefocusTest.java View File

@@ -1,17 +1,16 @@
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
@@ -19,14 +18,7 @@ import com.vaadin.testbench.parallel.Browser;
*
* @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() {
@@ -40,10 +32,16 @@ public class ModalWindowRefocusTest extends ModalWindowFocusTest {
*/
@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),
@@ -53,10 +51,14 @@ public class ModalWindowRefocusTest extends ModalWindowFocusTest {
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);
}

}

Loading…
Cancel
Save