Example usage for org.openqa.selenium Keys TAB

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

Introduction

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

Prototype

Keys TAB

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

Click Source Link

Usage

From source file:org.testeditor.fixture.web.WebFixtureTest.java

License:Open Source License

/**
 * Test for pressSpecialKey./*from www  .j av  a 2 s . c  o  m*/
 */
@Test
public void pressSpecialKeyWorksCorrect() {
    startWebApplication(WEB_INDEX_PAGE);

    assertTrue(fixture.pressSpecialKey(Keys.TAB.name()));

    try {
        fixture.pressSpecialKey("UnknownKey");
        fail("Exception for unknown key is expected");
    } catch (StopTestException e) {
        // exception for unknown key is expected
        assertTrue(true);
    }

    try {
        fixture.pressSpecialKey(null);
        fail("Exception for null is expected");
    } catch (StopTestException e) {
        // exception for null is expected
        assertTrue(true);
    }

    try {
        fixture.pressSpecialKey("");
        fail("Exception for empty key is expected");
    } catch (StopTestException e) {
        // exception for empty key is expected
        assertTrue(true);
    }
}

From source file:org.testeditor.fixture.web.WebFixtureTest.java

License:Open Source License

/**
 * Test for pressSpecialKeyOnElement./*  w  w  w.  ja  v  a2s.c  o m*/
 */
@Test
public void pressSpecialKeyOnElementWorksCorrectWithKnownKeys() {
    startWebApplication(WEB_INDEX_PAGE);

    fixture.insertIntoField("Max Mustermann", "user");
    fixture.insertIntoField("maxi", "password");
    fixture.pressSpecialKeyOnElement(Keys.TAB.name(), "user");
    fixture.pressSpecialKeyOnElement(Keys.TAB.name(), "user");
    fixture.pressSpecialKeyOnElement(Keys.ENTER.name(), "user");

    fixture.checkTextIsPresentOnPage("Eine Beispiel Web-Applikation");

    /* Not possible with HtmlUnitDriver but works with real Driver */
    // startWebApplication(WEB_ELEMENTS_PAGE);
    // assertTrue(fixture.checkIsSelected("checkbox"));
    // assertTrue(fixture.pressSpecialKeyOnElement(Keys.SPACE.name(),
    // "checkbox"));
    // assertFalse(fixture.checkIsSelected("checkbox"));
}

From source file:org.vaadin.testbenchsauce.BaseTestBenchTestCase.java

protected void unblurField(WebElement textField) {
    //Send TAB key - only works in Ghost driver (doesn't work in chrome, etc.)
    textField.sendKeys(Keys.TAB); //Otherwise when a "per character" text listener is used, the results of it will appear too late for hte next test assert. //Is this really working??? Only in Ghost driver.

    if (USE_CHROME_DRIVER) {
        //Also do a click on the root, works as unblur for chrome, etc but not ghost driver.
        System.out.println("TODO: find an innocuous area to click to force unblur");
        //findElement(By.id("logoContainer")).click(); //create a blur by click on a known innocuous part of the page
    }//from   ww w  .  j  a va 2s. c o  m
}

From source file:org.vaadin.testbenchsauce.BaseTestBenchTestCase.java

protected void setComboboxValue(WebElement element, String caption, String value) {
    doPreOperationChecks();/*from w  w w.  j  a v  a2s .com*/
    WebElement input = null;
    String xpathValue = "//div[contains(@class, 'v-caption')]/span[contains(text(),'" + caption
            + "')]/ancestor::tr[contains(@class,'v-formlayout-row')][1]//input";
    if (element == null) {
        //global search
        input = findElement(By.xpath(xpathValue));
    } else {
        //search within element that was passed in
        input = element.findElement(By.xpath("." + xpathValue));
    }
    assertNotNull("Could not find combobox with caption '" + caption + "'", input);
    input.click();
    input.sendKeys(value);
    input.sendKeys(Keys.TAB);
    assertFieldHasValue(caption, input, value);
    doPostOperationChecks();
}

From source file:org.wso2.ds.ui.integration.test.dashboard.BannerTest.java

License:Open Source License

/**
 * Creates a dashboard and change editor/viewer permissions.
 *
 * @throws MalformedURLException/*w w w. ja v a  2 s .c o  m*/
 * @throws XPathExpressionException
 */
private void initDashboard() throws MalformedURLException, XPathExpressionException {
    getDriver().get(getBaseUrl() + "/portal/dashboards");
    // Create dashboard
    getDriver().findElement(By.cssSelector("a[href='create-dashboard']")).click();
    getDriver().findElement(By.id("ues-dashboard-title")).clear();
    getDriver().findElement(By.id("ues-dashboard-title")).sendKeys(dashboardTitle);
    getDriver().findElement(By.id("ues-dashboard-create")).click();
    selectLayout("banner");
    // Change permissions
    getDriver().findElement(By.id("dashboard-settings")).click();
    getDriver().executeScript("scroll(0, 200);");
    getDriver().findElement(By.id("ues-share-view")).clear();
    getDriver().findElement(By.id("ues-share-view")).sendKeys("view");
    getDriver().findElement(By.id("ues-share-view")).sendKeys(Keys.TAB);
    getDriver().findElement(By.id("ues-share-edit")).clear();
    getDriver().findElement(By.id("ues-share-edit")).sendKeys("edit");
    getDriver().findElement(By.id("ues-share-edit")).sendKeys(Keys.TAB);
    // Remove other permissions
    getDriver()
            .findElement(By.cssSelector(
                    ".ues-shared-view .ues-shared-role[data-role=\"Internal/everyone\"] span.remove-button"))
            .click();
    getDriver()
            .findElement(By.cssSelector(
                    ".ues-shared-edit .ues-shared-role[data-role=\"Internal/everyone\"] span.remove-button"))
            .click();
    getDriver().findElement(By.id("ues-dashboard-saveBtn")).click();
    redirectToLocation("portal", "dashboards");
}

From source file:org.wso2.ds.ui.integration.test.dashboard.CreateCustomDashboardPerUser.java

License:Open Source License

/**
 * Assign dashboard viewers and editors.
 *
 * @throws XPathExpressionException/*  w w  w .ja  v a2s  .  co  m*/
 * @throws MalformedURLException
 */
@Test(groups = "wso2.ds.dashboard", description = "Assigning dashboard view and edit permission", dependsOnMethods = "testAddUserAssignRoles")
public void testAddDashboardAndAssignRolesBySetting() throws XPathExpressionException, MalformedURLException {
    login(USERNAME_EDITOR, PASSWORD_EDITOR);
    addDashBoard(dashboardTitle, DASHBOARD_DESCRIPTION);
    WebElement dashboardItem = getDriver().findElement(By.id(dashboardTitle.toLowerCase()));
    dashboardItem.findElement(By.cssSelector(".ues-edit")).click();
    getDriver().findElement(By.id("dashboard-settings")).click();
    getDriver().executeScript("scroll(0, 200);");
    // Add viewer role
    WebElement viewerTextbox = getDriver().findElement(By.id("ues-share-view"));
    viewerTextbox.sendKeys("dashboardViewer");
    viewerTextbox.sendKeys(Keys.TAB);
    // Add editor role
    WebElement editorTextbox = getDriver().findElement(By.id("ues-share-edit"));
    editorTextbox.sendKeys("dashboardEditor");
    editorTextbox.sendKeys(Keys.TAB);
    // Remove all other roles
    getDriver().findElement(By.cssSelector(".ues-shared-view > .ues-shared-role > .remove-button")).click();
    getDriver().findElement(By.cssSelector(".ues-shared-edit > .ues-shared-role > .remove-button")).click();
    getDriver().findElement(By.id("ues-dashboard-saveBtn")).click();
}

From source file:org.wso2.ds.ui.integration.test.dashboard.GadgetUserPrefTest.java

License:Open Source License

/**
 * Create the dashboard, select the layout template and change editor and viewer permissions
 *
 * @throws Exception/*from w w  w.  ja v a2 s.  c  o m*/
 */
private void initDashboard() throws Exception {
    DSWebDriver driver = getDriver();
    driver.get(getBaseUrl() + "/" + DS_HOME_CONTEXT + "/" + DS_DASHBOARDS_CONTEXT);
    // Create dashboard
    driver.findElement(By.cssSelector("a[href='create-dashboard']")).click();
    driver.findElement(By.id("ues-dashboard-title")).clear();
    driver.findElement(By.id("ues-dashboard-title")).sendKeys(dashboardTitle);
    driver.findElement(By.id("ues-dashboard-create")).click();
    selectLayout("default-grid");
    // Change permissions
    driver.findElement(By.id("dashboard-settings")).click();
    driver.executeScript("scroll(0, 200);");
    driver.findElement(By.id("ues-share-view")).clear();
    driver.findElement(By.id("ues-share-view")).sendKeys("viewer_userPr");
    driver.findElement(By.id("ues-share-view")).sendKeys(Keys.TAB);
    driver.findElement(By.id("ues-share-edit")).clear();
    driver.findElement(By.id("ues-share-edit")).sendKeys("editor_userPr");
    driver.findElement(By.id("ues-share-edit")).sendKeys(Keys.TAB);
    // Remove other permissions
    driver.findElement(By.cssSelector(
            ".ues-shared-view " + ".ues-shared-role[data-role=\"Internal/everyone\"] span.remove-button"))
            .click();
    driver.findElement(By.cssSelector(
            ".ues-shared-edit " + ".ues-shared-role[data-role=\"Internal/everyone\"] span.remove-button"))
            .click();
    driver.findElement(By.id("ues-dashboard-saveBtn")).click();
    redirectToLocation(DS_HOME_CONTEXT, DS_DASHBOARDS_CONTEXT);
}

From source file:org.xwiki.test.wysiwyg.framework.AbstractWysiwygTestCase.java

License:Open Source License

public void typeTab(int count) {
    sendKey(Keys.TAB, count, false);
}

From source file:org.xwiki.test.wysiwyg.framework.AbstractWysiwygTestCase.java

License:Open Source License

public void typeShiftTab() {
    getRichTextArea().sendKeys(Keys.chord(Keys.SHIFT, Keys.TAB));
}

From source file:org.xwiki.test.wysiwyg.HistoryTest.java

License:Open Source License

/**
 * Basic integration test for the history mechanism.
 *///from w w w . ja  v  a2 s  .co  m
@Test
public void testUndoRedo() {
    getRichTextArea().sendKeys("a b", Keys.TAB, "c");
    clickSymbolButton();
    getSelenium().click("//div[@title='copyright sign']");
    applyStyleTitle1();
    waitForPushButton(TOOLBAR_BUTTON_UNDO_TITLE, true);
    clickUndoButton(4);
    assertContent("a b<br>");
    clickUndoButton(3);
    assertContent("<br>");
    waitForPushButton(TOOLBAR_BUTTON_REDO_TITLE, true);
    clickRedoButton(7);
    assertContent("<h1>a b&nbsp;&nbsp;&nbsp; c\u00A9<br></h1>");
}