Example usage for org.openqa.selenium Keys ESCAPE

List of usage examples for org.openqa.selenium Keys ESCAPE

Introduction

In this page you can find the example usage for org.openqa.selenium Keys ESCAPE.

Prototype

Keys ESCAPE

To view the source code for org.openqa.selenium Keys ESCAPE.

Click Source Link

Usage

From source file:org.auraframework.components.ui.modalOverlay.Panel2ModalOverlayUITest.java

License:Apache License

private void verifyCloseOnEsc(String panelType, Boolean autoFocus)
        throws MalformedURLException, URISyntaxException, InterruptedException {
    String url = APP;/*from   www.  ja v a  2  s.c  om*/
    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();
    }
    WebElement activeElement = (WebElement) auraUITestingUtil.getEval(ACTIVE_ELEMENT);
    activeElement.sendKeys(Keys.ESCAPE);
    if (isPanel) {
        waitForPanelDialogClose();
    } else {
        waitForModalClose();
    }
}

From source file:org.auraframework.components.ui.modalOverlay.Panel2ModalOverlayUITest.java

License:Apache License

/**
 * Verify custom close action Bug: W-2619406
 *//* w ww.ja  v a2  s . c om*/
public void testPressEscKeyOnPanelDialogWhenCloseActionSet() throws Exception {
    open(APP + "?" + PARAM_PANEL_TYPE + "panel");
    WebElement enableCustomCloseAction = findDomElement(By.cssSelector(ENABLE_CUSTOM_CLOSEACTION));
    enableCustomCloseAction.click();

    openPanel();
    waitForPanelDialogOpen();

    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.components.ui.modalOverlay.Panel2ModalOverlayUITest.java

License:Apache License

private void verifyPressingEscOnMultipleModalDestorysModal(String locator, boolean autoFocus)
        throws MalformedURLException, URISyntaxException, InterruptedException {
    String url = APP;//  w w w .  j a va2 s.  c  om
    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");
    }

    WebElement firstModalPanel = findDomElements(By.cssSelector(locator)).get(0);
    assertTrue(String.format("First %s should have class active", errorMessage),
            firstModalPanel.getAttribute("class").contains("active"));
    // open second modal
    openPanel(2);
    waitForNumberOfPanels(locator, 2);

    WebElement secondModalPanel = findDomElements(By.cssSelector(locator)).get(1);
    assertFalse(String.format("First %s should have not have class active", errorMessage),
            firstModalPanel.getAttribute("class").contains("active"));
    assertTrue(String.format("Second %s should have class active", errorMessage),
            secondModalPanel.getAttribute("class").contains("active"));

    WebElement activeElement = (WebElement) auraUITestingUtil.getEval(ACTIVE_ELEMENT);
    activeElement.sendKeys(Keys.ESCAPE);
    waitForNumberOfPanels(locator, 1);

    assertTrue(String.format("First %s should have class active after press ESC on 2nd %s", errorMessage,
            errorMessage), firstModalPanel.getAttribute("class").contains("active"));

    activeElement = (WebElement) auraUITestingUtil.getEval(ACTIVE_ELEMENT);
    activeElement.sendKeys(Keys.ESCAPE);
    waitForNumberOfPanels(locator, 0);
}

From source file:org.auraframework.components.ui.modalOverlay.PanelModalOverlayUITest.java

License:Apache License

/**
 * Verify pressing ESC while modalOverlay dialog is opened should close the overlay
 * //  w w  w  .  j a  v a2s .c o m
 * @throws MalformedURLException
 * @throws URISyntaxException
 */
private void verifyPressEscKeyOnModalAndNonModalOverlay(String button, String cmp)
        throws MalformedURLException, URISyntaxException, InterruptedException {
    //verifyTabOutAndEscBehaviour(Keys.ESCAPE, false);
    open(APP);
    verifyOverlayActive(cmp, false);
    openOverlay(button);
    verifyOverlayActive(cmp, true);
    WebElement activeElement = (WebElement) auraUITestingUtil.getEval(ACTIVE_ELEMENT);
    activeElement.sendKeys(Keys.ESCAPE);
    verifyOverlayActive(cmp, false);
}

From source file:org.auraframework.components.ui.modalOverlay.PanelModalOverlayUITest.java

License:Apache License

/**
 * verify multiple overlay one above another on modal or nonModal should close all the overlay's when we press ESC on the newest overlay
 * @throws MalformedURLException//w w w  .  jav  a 2 s  .c o  m
 * @throws URISyntaxException
 * @throws InterruptedException
 */
public void verifyClickEscButtonClosesAllModalNonModalOverlays(String button)
        throws MalformedURLException, URISyntaxException, InterruptedException {
    open(APP);
    verifyOverlayActive(MODAL_OVERLAY_CMP, false);
    openOverlay(button);
    verifyOverlayActive(MODAL_OVERLAY_CMP, true);
    openNewOverlayOnTopOfExistingModalOverlay(2);
    verifyOverlayActive(MODAL_OVERLAY_CMP, true);
    WebElement activeElement = (WebElement) auraUITestingUtil.getEval(ACTIVE_ELEMENT);
    activeElement.sendKeys(Keys.ESCAPE);
    verifyOverlayActive(MODAL_OVERLAY_CMP, false);
}

From source file:org.auraframework.integration.test.components.ui.dialogUITest.DialogUITest.java

License:Apache License

@ExcludeBrowsers({ BrowserType.ANDROID_PHONE, BrowserType.ANDROID_TABLET, BrowserType.IPAD,
        BrowserType.IPHONE })/*w  ww.j a  va2 s  .c  om*/
@Test
public void testDialogNonModalEscapeButton() throws MalformedURLException, URISyntaxException {
    open(URL_NON_MODAL);

    WebDriver driver = getDriver();
    openDialogBox(driver);
    // Grab the focused element, then press escape to close dialog box
    String classOfActiveElem = "button[title*='" + getAuraUITestingUtil().getEval(TITLE) + "']";
    WebElement element = driver.findElement(By.cssSelector(classOfActiveElem));

    element.sendKeys(Keys.ESCAPE);

    // Wait for DialogBox to close
    waitForComponentToChangeStatus("div[class*='dialog']", "className", "hidden", false);

    // Make sure no data was submitted
    element = driver.findElement(By.cssSelector(RESULT_LABEL));
    assertEquals("The escape button submitted data, and it shouldn't have", NOT_SUBMITTED,
            element.getAttribute("value"));
}

From source file:org.auraframework.integration.test.components.ui.inputDate.InputDateWithLabelUITest.java

License:Apache License

@ExcludeBrowsers({ BrowserType.ANDROID_PHONE, BrowserType.ANDROID_TABLET, BrowserType.IPAD,
        BrowserType.IPHONE })//from ww w .  j a  v  a  2 s  .com
@Test
public void testEscape() throws Exception {
    open(URL);

    boolean escButtonClosedCal;

    openDatePicker();

    // Looking for the current date, which should be focused on
    WebElement element = findDomElement(By.cssSelector(SELECTED_DATE));

    // Hitting escape to close the Calendar
    element.sendKeys(Keys.ESCAPE);

    // Want to get a NoSuchElementExpection when looking for the class
    // if visible exists, that means that the calendar did not close
    element = findDomElement(By.cssSelector("div[class*='uiDatePicker']"));

    escButtonClosedCal = !element.getAttribute("class").contains("visible");

    assertTrue("Escape button did not close the calendar", escButtonClosedCal);
}

From source file:org.auraframework.integration.test.components.ui.inputDate.InputDateWithLabelUITest.java

License:Apache License

/**
 * Test Flow://from   w  w  w.  j  av a2 s. co  m
 * 1. Have focus on inputDate
 * 2. Tab onto the calendar icon and press enter
 * 3. After datepicker opens, press a button (ESC, ENTER, SPACE) to close it
 * 4. Check if inputDate has focus
 * @throws Exception
 */
// Testing the focus after closing datePicker
// Disabling for Safari since Safari does not handle tabs normally
@ExcludeBrowsers({ BrowserType.SAFARI, BrowserType.ANDROID_PHONE, BrowserType.ANDROID_TABLET, BrowserType.IPAD,
        BrowserType.IPHONE })

@Test
public void testFocusOnClosingDP() throws Exception {

    // the different keys we will use to close the datePicker
    Keys[] keysToClose = { Keys.ESCAPE, Keys.ENTER, Keys.SPACE };

    open(URL);

    for (int i = 0; i < keysToClose.length; i++) {

        WebElement inputDate = findDomElement(By.cssSelector(DATE_INPUT_BOX_SEL));
        inputDate.sendKeys(Keys.TAB);

        //active element should now be the calendar icon - hit enter to open datePicker
        WebElement activeElement = (WebElement) getAuraUITestingUtil().getEval(ACTIVE_ELEMENT);
        activeElement.sendKeys(Keys.ENTER);

        //datePicker should be open
        getAuraUITestingUtil().waitForElement("datePicker should been present, but its not",
                By.cssSelector(".uiDatePicker.visible"));

        //use key to close the datePicker
        WebElement selectedDate = findDomElement(By.cssSelector(SELECTED_DATE));
        selectedDate.sendKeys(keysToClose[i]);

        //check if datePicker is closed
        getAuraUITestingUtil().waitForElementNotPresent("datePicker should not be present, but it is",
                By.cssSelector(".uiDatePicker.visible"));

        //check if active element is the inputDate
        activeElement = (WebElement) getAuraUITestingUtil().getEval(ACTIVE_ELEMENT);
        assertEquals("Focus not on the right element", activeElement, inputDate);

    }
}

From source file:org.auraframework.integration.test.components.ui.inputDateTime.InputDateTimeUITest.java

License:Apache License

/**
 * Test Flow://from   w w  w.  j ava2 s  .c o m
 * - check if focus is back to inputTimeBox after pressing ESCAPE on timePicker
 * @throws Exception
 */
@Test
public void testTPFocusOnClosingWithEscapeKey() throws Exception {
    open(URL);
    checkTPFocusOnClosingWithKey(Keys.ESCAPE);
}

From source file:org.auraframework.integration.test.components.ui.inputDateTime.InputDateTimeUITest.java

License:Apache License

/**
 * Test Flow:// w  ww .  j av a2  s . c  o m
 * - check if focus is back to inputTimeBox after pressing SPACE on timePicker
 * @throws Exception
 */
@Test
public void testTPFocusOnClosingWithSpaceKey() throws Exception {
    open(URL);
    checkTPFocusOnClosingWithKey(Keys.ESCAPE);
}