List of usage examples for org.openqa.selenium Keys ESCAPE
Keys ESCAPE
To view the source code for org.openqa.selenium Keys ESCAPE.
Click Source Link
From source file:org.auraframework.integration.test.components.ui.listSorter.ListSorterUITest.java
License:Apache License
/** * Verify pressing ESC while listSorter is opened should close the list sorter * /* w ww. j ava 2s . co m*/ * @throws MalformedURLException * @throws URISyntaxException */ public void _testEscOfListSorter() throws MalformedURLException, URISyntaxException { verifyTabOutAndEscBehaviour(Keys.ESCAPE, false); }
From source file:org.auraframework.integration.test.components.ui.menu.MenuUITest.java
License:Apache License
private void testActionMenuViaKeyboardInteractionForApp(String appName, String appendString, boolean verifyLabelUpdate) throws Exception { open(appName);/* w ww .ja v a 2s . co m*/ WebDriver driver = this.getDriver(); String label = "trigger" + appendString; String menuName = "actionMenu" + appendString; String menuItem1 = "actionItem1" + appendString; String menuItem3 = "actionItem3" + appendString; String menuItem4 = "actionItem4" + appendString; WebElement menuLabel = driver.findElement(By.className(label)); WebElement actionMenu = driver.findElement(By.className(menuName)); openMenu(menuLabel, actionMenu); WebElement actionItem1 = driver.findElement(By.className(menuItem1)); WebElement actionItem1Element = getAnchor(actionItem1); WebElement actionItem3 = driver.findElement(By.className(menuItem3)); WebElement actionItem3Element = getAnchor(actionItem3); WebElement actionItem4 = driver.findElement(By.className(menuItem4)); WebElement actionItem4Element = getAnchor(actionItem4); // default focus on trigger assertEquals("Focus should be on the trigger", menuLabel.getText(), getAuraUITestingUtil().getActiveElementText()); // press down key once menuLabel.sendKeys(Keys.DOWN); // focus should be one the first item waitForFocusOnElement(actionItem1Element); actionItem1Element.sendKeys(Keys.DOWN, Keys.DOWN); // verify focus on action item3 getAuraUITestingUtil().setHoverOverElement(menuItem3); waitForFocusOnElement(actionItem3Element); actionItem3Element.click(); if (verifyLabelUpdate) { waitForMenuText(menuLabel, "Inter Milan"); } openMenu(menuLabel, actionMenu); getAuraUITestingUtil().setHoverOverElement(menuItem4); waitForFocusOnElement(actionItem4Element); actionItem4Element.sendKeys(Keys.UP); // verify focus on action item3 waitForFocusOnElement(actionItem3Element); // press space key and check if item3 got selected actionItem3Element.sendKeys(Keys.SPACE); if (verifyLabelUpdate) { waitForMenuText(menuLabel, "Inter Milan"); } openMenu(menuLabel, actionMenu); getAuraUITestingUtil().setHoverOverElement(menuItem1); waitForFocusOnElement(actionItem1Element); actionItem1Element.sendKeys(Keys.ESCAPE); waitForMenuClose(actionMenu); }
From source file:org.auraframework.integration.test.components.ui.menu.MenuUITest.java
License:Apache License
@ExcludeBrowsers({ BrowserType.IE11 }) public void testMenuRadio() throws Exception { open(MENUTEST_APP);/* w w w. ja v a 2 s.co m*/ WebDriver driver = this.getDriver(); String label = "radioMenuLabel"; String menuName = "radioMenu"; String menuItem3 = "radioItem3"; String menuItem4 = "radioItem4"; String menuItem5 = "radioItem5"; WebElement menuLabel = driver.findElement(By.className(label)); WebElement menu = driver.findElement(By.className(menuName)); // check for default label present assertEquals("label is wrong", "National League West", menuLabel.getText()); assertFalse("Default: CheckboxMenu list should not be visible", menu.getAttribute("class").contains("visible")); // open menu list openMenu(menuLabel, menu); WebElement item3 = driver.findElement(By.className(menuItem3)); WebElement item3Element = getAnchor(item3); WebElement item4 = driver.findElement(By.className(menuItem4)); WebElement item4Element = getAnchor(item4); WebElement item5 = driver.findElement(By.className(menuItem5)); WebElement item5Element = getAnchor(item5); WebElement button = driver.findElement(By.className("radioButton")); WebElement result = driver.findElement(By.className("radioMenuResult")); // click and verify item3 got selected item3Element.click(); getAuraUITestingUtil().waitUntil(check -> item3Element.getAttribute("class").contains("selected"), "Item3 should be selected after the click"); // send key to go to item 4 using 'd' item3Element.sendKeys("d"); waitForFocusOnElement(item4Element); // verify item is disabled assertTrue("Item4 aria attribute should be defaulted to disable", Boolean.valueOf(item4Element.getAttribute("aria-disabled"))); assertTrue("Item4 v.disabled should default to true", getCmpBoolAttribute(menuItem4, "v.disabled")); // click on item4 and verify item4 should not be selectable tryToClickDisabledElm(item4Element); assertFalse("Item4 should not be selectable as it's disable item", item4Element.getAttribute("class").contains("selected")); // goto item 5 using down arrow and check focus item4Element.sendKeys(Keys.DOWN); waitForFocusOnElement(item5Element); // click on item 5 using space item5Element.sendKeys(Keys.SPACE); getAuraUITestingUtil().waitUntil(check -> item5Element.getAttribute("class").contains("selected"), "Item5 should be checked after pressing Space"); assertFalse("Item3 should be unchecked after clicking item 5", item3Element.getAttribute("class").contains("selected")); // close the menu using esc key item5Element.sendKeys(Keys.ESCAPE); // check the result button.click(); assertEquals("Checkbox items selected are not correct", "Colorado", result.getText()); }
From source file:org.auraframework.integration.test.components.ui.modalOverlay.Panel2ModalOverlayUITest.java
License:Apache License
private void verifyCloseOnEsc(String panelType, Boolean autoFocus) throws MalformedURLException, URISyntaxException, InterruptedException { String url = APP;//from w w w . j av a 2s .co m boolean isPanel = panelType.contains("panel"); if (isPanel) { url += "?" + PARAM_PANEL_TYPE + panelType; } open(url); if (!autoFocus) { // disable autoFocus WebElement autoFocusElement = findDomElement(By.cssSelector(INPUT_AUTOFOCUS)); autoFocusElement.click(); } openPanel(); if (isPanel) { waitForPanelDialogOpen(); } else { waitForModalOpen(); } if (autoFocus) { waitTillFocusOnTopElement(); } else { waitTillFocusOnParticularElement(CLOSE_BTN, "Focus should be on closeBtn"); } WebElement activeElement = (WebElement) getAuraUITestingUtil().getEval(ACTIVE_ELEMENT); activeElement.sendKeys(Keys.ESCAPE); if (isPanel) { waitForPanelDialogClose(); } else { waitForModalClose(); } }
From source file:org.auraframework.integration.test.components.ui.modalOverlay.Panel2ModalOverlayUITest.java
License:Apache License
/** * Verify custom close action Bug: W-2619406 *//*w w w . j a v a 2 s .co m*/ @Test public void testPressEscKeyOnPanelDialogWhenCloseActionSet() throws Exception { open(APP + "?" + PARAM_PANEL_TYPE + "panel"); WebElement enableCustomCloseAction = findDomElement(By.cssSelector(ENABLE_CUSTOM_CLOSEACTION)); enableCustomCloseAction.click(); openPanel(); waitForPanelDialogOpen(); waitTillFocusOnTopElement(); WebElement fistInputElement = findDomElements(By.cssSelector(INPUT_PANELTYPE)).get(1); fistInputElement.click(); fistInputElement.sendKeys(Keys.ESCAPE); // ESC does not close the panel waitForPanelDialogOpen(); String actionType = "closeOnEsc"; verifyCustomCloseActionMethodCalled(actionType); }
From source file:org.auraframework.integration.test.components.ui.modalOverlay.Panel2ModalOverlayUITest.java
License:Apache License
private void verifyPressingEscOnMultipleModalDestorysModal(String locator, boolean autoFocus) throws MalformedURLException, URISyntaxException, InterruptedException { String url = APP;/*from w w w .java2s .co m*/ boolean isPanel = locator.contains(PANEL_DIALOG); String errorMessage = "modal"; if (isPanel) { url += "?" + PARAM_PANEL_TYPE + "panel"; errorMessage = "panel"; } open(url); // disable autoFocus for modal 1 if (!autoFocus) { WebElement autoFocusElement = findDomElement(By.cssSelector(INPUT_AUTOFOCUS)); autoFocusElement.click(); } openPanel(); if (locator.contains(PANEL_MODAL)) { waitForModalOpen(); } else { waitForPanelDialogOpen(); WebElement fistInputElement = findDomElements(By.cssSelector(INPUT_PANELTYPE)).get(1); fistInputElement.clear(); fistInputElement.click(); fistInputElement.sendKeys("panel"); } verifyModalPanelIsActive(String.format("First %s should have class active", errorMessage), locator, true, 0); openPanel(2); waitForNumberOfPanels(locator, 2); verifyModalPanelIsActive( String.format("First %s should not have class active after opening second modal", errorMessage), locator, false, 0); verifyModalPanelIsActive(String.format("Second %s should have class active", errorMessage), locator, true, 1); waitTillFocusOnTopElement(); WebElement activeElement = (WebElement) getAuraUITestingUtil().getEval(ACTIVE_ELEMENT); activeElement.sendKeys(Keys.ESCAPE); waitForNumberOfPanels(locator, 1); verifyModalPanelIsActive(String.format("First %s should have class active after press ESC on 2nd %s", errorMessage, errorMessage), locator, true, 0); activeElement = (WebElement) getAuraUITestingUtil().getEval(ACTIVE_ELEMENT); activeElement.sendKeys(Keys.ESCAPE); waitForNumberOfPanels(locator, 0); }
From source file:org.auraframework.integration.test.localization.LocalizationAppUITest.java
License:Apache License
@ExcludeBrowsers({ BrowserType.IE9, BrowserType.IE10, BrowserType.SAFARI, BrowserType.ANDROID_PHONE, BrowserType.ANDROID_TABLET, BrowserType.IPAD, BrowserType.IPHONE }) // Checking functionality of the inputDate/outputDate components @Test//w w w . ja va 2s . co m public void testDateComponents() throws Exception { open(URL); // initial load WebElement elementInput = findDomElement(By.cssSelector(".uiInputDate .input")); WebElement elementoutput = findDomElement(By.cssSelector(".uiOutputDate")); assertEquals("InputDate component rendered with wrong value", "Sep 23, 2004", elementInput.getAttribute("value")); assertEquals("outputDate component rendered with wrong value", "Sep 23, 2004", elementoutput.getText()); // Tab out elementInput.click(); elementInput.clear(); elementInput.sendKeys("Sep 23, 2005"); getAuraUITestingUtil().pressTab(elementInput); assertEquals("InputDate component rendered with wrong value", "Sep 23, 2005", elementInput.getAttribute("value")); assertEquals("outputDate component rendered with wrong value", "Sep 23, 2005", elementoutput.getText()); // Submit click elementInput.click(); elementInput.clear(); elementInput.sendKeys("Sep 23, 2006"); // Hide the datepicker WebElement yearSelector = findDomElement(By.cssSelector(".visible select")); yearSelector.sendKeys(Keys.ESCAPE); WebElement elementButton = findDomElement(By.cssSelector("button[title~='Date']")); elementButton.click(); assertEquals("InputDate component rendered with wrong value", "Sep 23, 2006", elementInput.getAttribute("value")); assertEquals("outputDate component rendered with wrong value", "Sep 23, 2006", elementoutput.getText()); }
From source file:org.eclipse.che.selenium.core.action.MacOSActionsTest.java
License:Open Source License
@Test public void testShouldReplaceEndCharSequence() throws Exception { MacOSActions actions = new MacOSActions(webDriver); final CharSequence[] charSequences = actions.modifyCharSequence(Keys.ESCAPE, Keys.END); assertNotNull(charSequences);// w w w . j a v a2s .co m assertEquals(charSequences.length, 2); assertEquals(charSequences[0], Keys.ESCAPE); assertEquals(charSequences[1], Keys.chord(Keys.COMMAND, Keys.RIGHT)); }
From source file:org.eclipse.che.selenium.core.action.MacOSActionsTest.java
License:Open Source License
@Test public void testShouldReplaceHomeCharSequence() throws Exception { MacOSActions actions = new MacOSActions(webDriver); final CharSequence[] charSequences = actions.modifyCharSequence(Keys.ESCAPE, Keys.HOME); assertNotNull(charSequences);//from w ww. j a va 2s . c o m assertEquals(charSequences.length, 2); assertEquals(charSequences[0], Keys.ESCAPE); assertEquals(charSequences[1], Keys.chord(Keys.COMMAND, Keys.LEFT)); }
From source file:org.eclipse.che.selenium.core.action.MacOSActionsTest.java
License:Open Source License
@Test public void testShouldReplacePageDownCharSequence() throws Exception { MacOSActions actions = new MacOSActions(webDriver); final CharSequence[] charSequences = actions.modifyCharSequence(Keys.ESCAPE, Keys.PAGE_DOWN); assertNotNull(charSequences);/*from w w w . j a v a2 s. c o m*/ assertEquals(charSequences.length, 2); assertEquals(charSequences[0], Keys.ESCAPE); assertEquals(charSequences[1], Keys.chord(Keys.COMMAND, Keys.DOWN)); }