List of usage examples for org.openqa.selenium.interactions Actions Actions
public Actions(WebDriver driver)
From source file:com.vaadin.tests.components.grid.basicfeatures.server.GridEditorTest.java
License:Apache License
@Test public void testNoOpenFromHeaderOrFooter() { selectMenuPath("Component", "Footer", "Visible"); getGridElement().getHeaderCell(0, 0).doubleClick(); assertEditorClosed();/*from w w w . j a v a 2 s . c om*/ new Actions(getDriver()).sendKeys(Keys.ENTER).perform(); assertEditorClosed(); getGridElement().getFooterCell(0, 0).doubleClick(); assertEditorClosed(); new Actions(getDriver()).sendKeys(Keys.ENTER).perform(); assertEditorClosed(); }
From source file:com.vaadin.tests.components.grid.basicfeatures.server.GridEditorUnbufferedTest.java
License:Apache License
@Test public void testEditorMoveWithKeyboard() throws InterruptedException { selectMenuPath(EDIT_ITEM_100);/*from w ww . ja v a 2s . co m*/ assertEditorOpen(); getEditorWidgets().get(0).click(); new Actions(getDriver()).sendKeys(Keys.ENTER).perform(); String firstFieldValue = getEditorWidgets().get(0).getAttribute("value"); assertEquals("Editor should move to row 101", "(101, 0)", firstFieldValue); for (int i = 0; i < 10; i++) { new Actions(getDriver()).keyDown(Keys.SHIFT).sendKeys(Keys.ENTER).keyUp(Keys.SHIFT).perform(); firstFieldValue = getEditorWidgets().get(0).getAttribute("value"); int row = 100 - i; assertEquals("Editor should move to row " + row, "(" + row + ", 0)", firstFieldValue); } }
From source file:com.vaadin.tests.components.grid.basicfeatures.server.GridEditorUnbufferedTest.java
License:Apache License
@Test public void testScrollEnabledOnMouseOpen() { int originalScrollPos = getGridVerticalScrollPos(); GridCellElement cell_5_0 = getGridElement().getCell(5, 0); new Actions(getDriver()).doubleClick(cell_5_0).perform(); scrollGridVerticallyTo(100);//from w w w . j av a 2 s. c o m assertGreater("Grid should scroll vertically while editing in unbuffered mode", getGridVerticalScrollPos(), originalScrollPos); }
From source file:com.vaadin.tests.components.grid.basicfeatures.server.GridEditorUnbufferedTest.java
License:Apache License
@Test public void testScrollEnabledOnKeyboardOpen() { int originalScrollPos = getGridVerticalScrollPos(); GridCellElement cell_5_0 = getGridElement().getCell(5, 0); cell_5_0.click();//w w w . j a va 2 s . c o m new Actions(getDriver()).sendKeys(Keys.ENTER).perform(); scrollGridVerticallyTo(100); assertGreater("Grid should scroll vertically while editing in unbuffered mode", getGridVerticalScrollPos(), originalScrollPos); }
From source file:com.vaadin.tests.components.grid.basicfeatures.server.GridItemClickTest.java
License:Apache License
@Test public void testItemClick() { openTestURL();/* w ww . java2 s . c o m*/ selectMenuPath("Component", "State", "ItemClickListener"); GridCellElement cell = getGridElement().getCell(3, 2); new Actions(getDriver()).moveToElement(cell).click().perform(); assertTrue("No click in log", logContainsText(itemClickOn(3, 2, false))); }
From source file:com.vaadin.tests.components.grid.basicfeatures.server.GridItemClickTest.java
License:Apache License
@Test public void testItemDoubleClick() { openTestURL();/*from w ww. java2s .c om*/ selectMenuPath("Component", "State", "ItemClickListener"); GridCellElement cell = getGridElement().getCell(3, 2); new Actions(getDriver()).moveToElement(cell).doubleClick().perform(); assertTrue("No double click in log", logContainsText(itemClickOn(3, 2, true))); }
From source file:com.vaadin.tests.components.grid.basicfeatures.server.GridKeyboardNavigationTest.java
License:Apache License
@Test public void testSimpleKeyboardNavigation() { openTestURL();// w w w . j a va2 s . co m GridElement grid = getGridElement(); grid.getCell(0, 0).click(); new Actions(getDriver()).sendKeys(Keys.ARROW_DOWN).perform(); assertTrue("Body cell 1, 0 is not focused after keyboard navigation.", grid.getCell(1, 0).isFocused()); new Actions(getDriver()).sendKeys(Keys.ARROW_RIGHT).perform(); assertTrue("Body cell 1, 1 is not focused after keyboard navigation.", grid.getCell(1, 1).isFocused()); int i; for (i = 1; i < 40; ++i) { new Actions(getDriver()).sendKeys(Keys.ARROW_DOWN).perform(); } assertFalse("Grid has not scrolled with cell focus", isElementPresent(By.xpath("//td[text() = '(0, 0)']"))); assertTrue("Cell focus is not visible", isElementPresent(By.xpath("//td[text() = '(" + i + ", 0)']"))); assertTrue("Body cell " + i + ", 1 is not focused", grid.getCell(i, 1).isFocused()); }
From source file:com.vaadin.tests.components.grid.basicfeatures.server.GridKeyboardNavigationTest.java
License:Apache License
@Test public void testNavigateFromHeaderToBody() { openTestURL();//from ww w .j a va 2s . c o m GridElement grid = getGridElement(); grid.scrollToRow(300); new Actions(driver).moveToElement(grid.getHeaderCell(0, 7)).click().perform(); grid.scrollToRow(280); assertTrue("Header cell is not focused.", grid.getHeaderCell(0, 7).isFocused()); new Actions(getDriver()).sendKeys(Keys.ARROW_DOWN).perform(); assertTrue("Body cell 280, 7 is not focused", grid.getCell(280, 7).isFocused()); }
From source file:com.vaadin.tests.components.grid.basicfeatures.server.GridKeyboardNavigationTest.java
License:Apache License
@Test public void testNavigationFromFooterToBody() { openTestURL();/*from w w w .j a v a2 s . co m*/ selectMenuPath("Component", "Footer", "Visible"); GridElement grid = getGridElement(); grid.scrollToRow(300); grid.getFooterCell(0, 2).click(); assertTrue("Footer cell does not have focus.", grid.getFooterCell(0, 2).isFocused()); new Actions(getDriver()).sendKeys(Keys.ARROW_UP).perform(); assertTrue("Body cell 300, 2 does not have focus.", grid.getCell(300, 2).isFocused()); }
From source file:com.vaadin.tests.components.grid.basicfeatures.server.GridKeyboardNavigationTest.java
License:Apache License
@Test public void testNavigateBetweenHeaderAndBodyWithTab() { openTestURL();// ww w . j av a2 s . c o m GridElement grid = getGridElement(); grid.getCell(10, 2).click(); assertTrue("Body cell 10, 2 does not have focus", grid.getCell(10, 2).isFocused()); new Actions(getDriver()).keyDown(Keys.SHIFT).sendKeys(Keys.TAB).keyUp(Keys.SHIFT).perform(); assertTrue("Header cell 0, 2 does not have focus", grid.getHeaderCell(0, 2).isFocused()); new Actions(getDriver()).sendKeys(Keys.TAB).perform(); assertTrue("Body cell 10, 2 does not have focus", grid.getCell(10, 2).isFocused()); // Navigate out of the Grid and try to navigate with arrow keys. new Actions(getDriver()).keyDown(Keys.SHIFT).sendKeys(Keys.TAB).sendKeys(Keys.TAB).keyUp(Keys.SHIFT) .sendKeys(Keys.ARROW_DOWN).perform(); assertTrue("Header cell 0, 2 does not have focus", grid.getHeaderCell(0, 2).isFocused()); }