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:com.vaadin.testbench.elements.DateTimeFieldElement.java

License:Apache License

/**
 * Set value of the date field element./*  ww  w  .j  a va2 s.c o m*/
 *
 * @param chars
 *            new value of the date field
 * @throws ReadOnlyException
 *             if the date field is in readonly mode
 */
public void setValue(CharSequence chars) throws ReadOnlyException {
    if (isReadOnly()) {
        throw new ReadOnlyException();
    }
    WebElement elem = findElement(By.tagName("input"));
    TestBenchElement tbElement = (TestBenchElement) elem;
    clearElementClientSide(tbElement);
    tbElement.sendKeys(chars);
    tbElement.sendKeys(Keys.TAB);
}

From source file:com.vaadin.testbench.elements.TextAreaElement.java

License:Apache License

@Override
public void setValue(CharSequence chars) {
    if (isReadOnly()) {
        throw new ReadOnlyException();
    }//w  w w .java2  s . com
    // clears without triggering an event
    clearElementClientSide(this);
    focus();
    sendKeys(chars);
    sendKeys(Keys.TAB);
}

From source file:com.vaadin.tests.components.datefield.LegacyDateFieldIsValidTest.java

License:Apache License

@Test
public void testInvalidText() throws Exception {
    openTestURL();/*from   www .  ja v  a 2s .c  om*/

    waitForElementVisible(By.id("Log"));
    waitForElementVisible(By.className("v-datefield"));
    WebElement dateTextbox = $(DateFieldElement.class).first().findElement(By.className("v-textfield"));
    ButtonElement button = $(ButtonElement.class).first();

    dateTextbox.sendKeys("01/01/01", Keys.TAB);
    assertLogText("1. valueChange: value: 01/01/01, is valid: true");
    button.click();
    assertLogText("2. buttonClick: value: 01/01/01, is valid: true");

    dateTextbox.sendKeys("lala", Keys.TAB);
    assertLogText("3. valueChange: value: null, is valid: false");
    button.click();
    assertLogText("4. buttonClick: value: null, is valid: false");

    dateTextbox.clear();
    dateTextbox.sendKeys("02/02/02", Keys.TAB);
    assertLogText("5. valueChange: value: 02/02/02, is valid: true");
    button.click();
    assertLogText("6. buttonClick: value: 02/02/02, is valid: true");
}

From source file:com.vaadin.tests.components.datefield.PopupDateFieldInputPromptTest.java

License:Apache License

@Test
public void testInputPrompt() {
    openTestURL();//  ww  w . j  a  v  a 2  s  .  c o  m
    TextFieldElement textField = $(TextFieldElement.class).first();
    final PopupDateFieldElement dateField = $(PopupDateFieldElement.class).first();

    // ensure initial state
    Assert.assertFalse("DateField required when it shouldn't be.", isRequired(dateField));
    WebElement input = dateField.findElement(By.className("v-textfield"));
    Assert.assertEquals("prompt", input.getAttribute("value"));

    // trigger ValueChange and move focus
    textField.sendKeys("foo", Keys.TAB);

    // wait for ValueChange to update DateField's state and the DateField to
    // gain focus.
    waitForElementRequiredAndFocused(dateField, By.className("v-textfield-focus"));

    // ensure prompt hasn't come back when field was set required
    Assert.assertNotEquals("prompt", input.getAttribute("value"));
}

From source file:com.vaadin.tests.components.grid.basicfeatures.server.GridKeyboardNavigationTest.java

License:Apache License

@Test
public void testNavigateBetweenHeaderAndBodyWithTab() {
    openTestURL();/* ww  w .j a v a  2s  .  co 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());
}

From source file:com.vaadin.tests.components.grid.basicfeatures.server.GridKeyboardNavigationTest.java

License:Apache License

@Test
public void testNavigateBetweenFooterAndBodyWithTab() {
    openTestURL();/*from w  w  w .ja v a2 s.  c o  m*/

    selectMenuPath("Component", "Footer", "Visible");

    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()).sendKeys(Keys.TAB).perform();
    assertTrue("Footer cell 0, 2 does not have focus", grid.getFooterCell(0, 2).isFocused());
    new Actions(getDriver()).keyDown(Keys.SHIFT).sendKeys(Keys.TAB).keyUp(Keys.SHIFT).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()).sendKeys(Keys.TAB).sendKeys(Keys.TAB).sendKeys(Keys.ARROW_UP).perform();
    assertTrue("Footer cell 0, 2 does not have focus", grid.getFooterCell(0, 2).isFocused());
}

From source file:com.vaadin.tests.components.grid.GridThemeUITest.java

License:Apache License

@Test
public void editor() throws Exception {
    openTestURL();//from w  w  w  . ja v  a2s.  co m
    selectPage("Editor");
    GridCellElement ritaBirthdate = grid.getCell(2, 3);
    // Open editor row
    openEditor(ritaBirthdate);

    compareScreen("initial");

    GridEditorElement editor = grid.getEditor();

    DateFieldElement dateField = editor.$(DateFieldElement.class).first();
    WebElement input = dateField.findElement(By.xpath("input"));
    input.sendKeys("Invalid", Keys.TAB);
    editor.save();
    compareScreen("one-invalid");

    TextFieldElement age = editor.$(TextFieldElement.class).caption("Age").first();
    age.sendKeys("abc", Keys.TAB);
    editor.save();

    compareScreen("two-invalid");
}

From source file:com.vaadin.v7.tests.components.grid.basicfeatures.escalator.EscalatorSpacerTest.java

License:Apache License

private void tryToTabIntoFocusUpdaterElement() {
    ((TestBenchElement) findElement(By.className("gwt-MenuBar"))).focus();
    WebElement focusedElement = getFocusedElement();
    focusedElement.sendKeys(Keys.TAB);
}

From source file:com.westconcomster.MO365.java

public void mo365Order(WebDriver driver, String region) throws InterruptedException {

    String winHandleBefore = driver.getWindowHandle();
    Thread.sleep(10000);//from  www .  jav  a 2s  .co m
    driver.findElement(By.xpath("//p[contains(.,'Buy Now')]")).click();

    //Select the customer
    for (String winHandle : driver.getWindowHandles()) {
        driver.switchTo().window(winHandle);
        System.out.println(">>>>>>>>>>inside child window");

        //Search for the customer
        Thread.sleep(5000);
        WebElement searchCust = driver.findElement(By.xpath("(.//*[@id='search_value'])[4]"));
        searchCust.clear();
        searchCust.sendKeys(Constants.companyName);
        Thread.sleep(5000);
        driver.findElement(By.xpath(
                ".//*[@id='customersList']/div[1]/ul/div[1]/div/div[2]/div/ecommerceselectable-customer/div/div[3]/div"))
                .click();

        //Select MO365
        WebElement searchProduct = driver.findElement(By.xpath("(.//*[@id='search_value'])[5]"));
        searchProduct.clear();
        searchProduct.sendKeys("MO365");
        Thread.sleep(2000);
        driver.findElement(By.xpath("//ecommerceselectable-product/div/div[3]/div/p")).click();
        (new WebDriverWait(driver, 60))
                .until(ExpectedConditions.visibilityOfElementLocated(By.xpath("//input[@name='quoteName']")))
                .sendKeys("LATAM_MO365_Order");

        Select dropdown = new Select(driver.findElement(By.name("root[contract][supportLevel]")));
        dropdown.selectByIndex(1);

        //Add reseller Margin
        driver.findElement(By.name("root[contract][resellermargin]")).clear();
        driver.findElement(By.name("root[contract][resellermargin]")).sendKeys("10");
        System.out.println(">>>>>>>Reseller Margin Added");
        driver.findElement(By.name("root[contract][billenduser]")).click();
        System.out.println(">>>>>>>>Bill End User");
        JavascriptExecutor jse = (JavascriptExecutor) driver;
        jse.executeScript("window.scrollBy(0,350)", "");
        Thread.sleep(5000);

        //select license
        MO365Licences mo365lic = new MO365Licences();
        mo365lic.mo365Licences(driver, region);
        //Select MO365 Add-ons
        MO365AddOns moadd = new MO365AddOns();
        moadd.mo365AddOns(driver, region);

        //Select Westcon Services
        MO365WestconServices mo365WS = new MO365WestconServices();
        mo365WS.mo365WestconServices(driver, region);

        //Total price
        WebElement price = (new WebDriverWait(driver, 60)).until(
                ExpectedConditions.visibilityOfElementLocated(By.xpath(".//*[text()[contains(.,'Total:')]]")));
        String totalAmt = price.getText().substring(price.getText().indexOf(":") + 1).trim();
        System.out.println(">>>>>>>>>>>TotalAmount" + totalAmt);

        //Click Next Button
        (new WebDriverWait(driver, 20).until(
                ExpectedConditions.visibilityOfElementLocated(By.xpath(".//button[contains(text(),'Next')]"))))
                        .click();
        Thread.sleep(10000);
        driver.findElement(By.xpath(".//button[contains(text(),'Submit Order')]")).click();

        //Add domain
        WebElement domain1 = (new WebDriverWait(driver, 30).until(ExpectedConditions
                .visibilityOfElementLocated(By.xpath("//input[@name='root[microsoft_info][domain_prefix]']"))));
        domain1.sendKeys(Constants.domian);
        domain1.sendKeys(Keys.TAB);
        Thread.sleep(10000);

        //Click on Submit Order
        WebElement submit = (new WebDriverWait(driver, 20).until(ExpectedConditions
                .visibilityOfElementLocated(By.xpath("//button[contains(text(),'Submit Order')]"))));
        submit.click();
        System.out.println(">>>>>>>>Order Submitted ");
        Thread.sleep(10000);

        //PO Number
        String orderNumber = driver.findElement(By.xpath(".//ecommercewizardstep[4]/section/div/div[2]/p"))
                .getText().replaceAll("\\D", "").trim();
        ;
        System.out.println(">>>>>>>>>>>Order number" + orderNumber);

        //Click on Close Button
        driver.findElement(By.xpath("//ecommercewizardstep[4]/section/div/div[2]/article/button[2]")).click();
        driver.switchTo().window(winHandleBefore);

        //*******Verify Order on Portal
        Thread.sleep(10000);
        String orderScreenOrder = driver.findElement(By.xpath(
                ".//*[@id='orders']/div/section[2]/div[1]/div[2]/div/div[2]/div/order/div[1]/div/div[1]/div[3]/div/div[1]/div[2]/div[2]"))
                .getText();
        System.out.println(">>>>>>>>>> OrderID" + orderScreenOrder);
        if (orderScreenOrder.equals(orderNumber)) {
            System.out.println(">>>>>> PASS <<<<<<< MO365 Order Created Successfully on portal");
        } else {
            System.out.println("Order FAILED");
        }
    }

}

From source file:com.westconcomster.MO365AddOns.java

public void mo365AddOns(WebDriver driver, String region) throws InterruptedException {

    //1. Office 365 Extra File Storage
    driver.findElement(By.xpath(//from   www  .  j  a  v a2  s .  c om
            ".//select[@name='root[product][licenses][addons][microsoftaddonsms796b6b5f-613c-4e24-a17c-eba730d49c02][ms53fc25f7-6639-4f78-bb44-3c2dfec3ed40][include]']"))
            .click();
    WebElement aOn2 = driver.findElement(By.xpath(
            ".//select[@name='root[product][licenses][addons][microsoftaddonsms796b6b5f-613c-4e24-a17c-eba730d49c02][ms53fc25f7-6639-4f78-bb44-3c2dfec3ed40][include]']/option[1]"));
    aOn2.sendKeys("YES");
    aOn2.sendKeys(Keys.TAB);
    Thread.sleep(1000);

    //2. Exchange Online Advanced Threat Protection
    driver.findElement(By.xpath(
            ".//select[@name='root[product][licenses][addons][microsoftaddonsms796b6b5f-613c-4e24-a17c-eba730d49c02][msa2706f86-868d-4048-989b-0c69e5c76b63][include]']"))
            .click();
    WebElement aOn3 = driver.findElement(By.xpath(
            ".//select[@name='root[product][licenses][addons][microsoftaddonsms796b6b5f-613c-4e24-a17c-eba730d49c02][msa2706f86-868d-4048-989b-0c69e5c76b63][include]']/option[1]"));
    aOn3.sendKeys("YES");
    aOn3.sendKeys(Keys.TAB);
    Thread.sleep(1000);

    //3. Skype for Business Cloud PBX
    driver.findElement(By.xpath(
            ".//select[@name='root[product][licenses][addons][microsoftaddonsms796b6b5f-613c-4e24-a17c-eba730d49c02][ms4260988e-990d-479c-ae7b-f01ce8e1bb4d][include]']"))
            .click();
    WebElement aOn4 = driver.findElement(By.xpath(
            ".//select[@name='root[product][licenses][addons][microsoftaddonsms796b6b5f-613c-4e24-a17c-eba730d49c02][ms4260988e-990d-479c-ae7b-f01ce8e1bb4d][include]']/option[1]"));
    aOn4.sendKeys("YES");
    aOn4.sendKeys(Keys.TAB);
    Thread.sleep(1000);

    //4. Office 365 Advanced eDiscovery
    driver.findElement(By.xpath(
            ".//select[@name='root[product][licenses][addons][microsoftaddonsms91fd106f-4b2c-4938-95ac-f54f74e9a239][ms6b648c1e-f472-46c0-8379-09f50a3315e0][include]']"))
            .click();
    WebElement aOn7 = driver.findElement(By.xpath(
            ".//select[@name='root[product][licenses][addons][microsoftaddonsms91fd106f-4b2c-4938-95ac-f54f74e9a239][ms6b648c1e-f472-46c0-8379-09f50a3315e0][include]']/option[1]"));
    aOn7.sendKeys("YES");
    aOn7.sendKeys(Keys.TAB);
    Thread.sleep(1000);

    //5. Delve Analytics
    driver.findElement(By.xpath(
            ".//select[@name='root[product][licenses][addons][microsoftaddonsms91fd106f-4b2c-4938-95ac-f54f74e9a239][ms45320ec9-9b8e-49d0-b900-f14141a0abd1][include]']"))
            .click();
    WebElement aOn8 = driver.findElement(By.xpath(
            ".//select[@name='root[product][licenses][addons][microsoftaddonsms91fd106f-4b2c-4938-95ac-f54f74e9a239][ms45320ec9-9b8e-49d0-b900-f14141a0abd1][include]']/option[1]"));
    aOn8.sendKeys("YES");
    aOn8.sendKeys(Keys.TAB);
    Thread.sleep(1000);

}