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:DesktopChosenIT.java

License:Apache License

/**
 * Goal: verify that tab navigation is possible when Chosen is within a form.
 */// w  w w  . j av a  2s. c om
@Test
public void tabNavigation() {
    // Given
    loadTestCase(new TabNavigation());

    // When
    webDriverWait().until(elementToBeClickable(By.id("firstTextBox")));

    webDriver.switchTo().activeElement().sendKeys(Keys.TAB);
    webDriver.switchTo().activeElement().sendKeys(Keys.TAB);

    // at this point, focus is on the Chosen widget
    final String searchText = "ferr";
    webDriver.switchTo().activeElement().sendKeys(searchText);

    final WebElement inputBox = getInput();

    // Then
    webDriverWait().until(new Predicate<WebDriver>() {
        @Override
        public boolean apply(@Nullable WebDriver input) {
            String value = inputBox.getAttribute("value");
            return value != null && value.equals(searchText);
        }
    });
}

From source file:appModules.Provider_reg_Action.java

public static void reg(int iTestCaseRow) throws Exception {
    try {/* w  w w. ja  va  2 s .  c o m*/
        String url = ExcelUtils.getCellData(iTestCaseRow, Constant.Col_URL);
        System.out.println("provider:" + url);
        ProviderRegistrationPage.geturl(Constant.micurl + url);
        //Log.info("Navigated to Registration page successfully");
        //ProviderRegistrationPage.geturl("https://cos.triplefin.com/triplefin/microsite/d8eds");
        ProviderRegistrationPage.button_Register().click();
        Utils.implicitwait();
        Log.info("Clicked on Register button successfulylly");

        String npinum = ExcelUtils.getCellData(iTestCaseRow, Constant.Col_npiNumber);
        System.out.println(npinum);
        ProviderRegistrationPage.txtbox_NPInumber().click();
        ProviderRegistrationPage.txtbox_NPInumber().sendKeys(npinum);
        Thread.sleep(2000);
        ProviderRegistrationPage.txtbox_NPInumber().sendKeys(Keys.TAB);
        Thread.sleep(5000);
        Log.info("Entered NPI number");

        String Address1 = ExcelUtils.getCellData(iTestCaseRow, Constant.Col_Address1);
        ProviderRegistrationPage.txtbox_Address1().sendKeys(Address1);
        Log.info("Entered Address 1 successfully");

        String deanum = ExcelUtils.getCellData(iTestCaseRow, Constant.Col_deaNumber);
        ProviderRegistrationPage.txtbox_deanumber().clear();
        ProviderRegistrationPage.txtbox_deanumber().sendKeys(deanum);
        Log.info("Entered DEA number successfulylly");

        String licenceNumber = ExcelUtils.getCellData(iTestCaseRow, Constant.Col_licenceNumber);
        ProviderRegistrationPage.txtbox_licenceNumber().clear();
        ProviderRegistrationPage.txtbox_licenceNumber().sendKeys(licenceNumber);
        Log.info("Entered license number successfulylly");

        String email = utility.CommonFunctions.getRandomString(5) + "@triplefin.com";
        ProviderRegistrationPage.txtbox_email().sendKeys(email);
        Log.info("Email entered successfulylly");

        ProviderRegistrationPage.txtbox_dob().click();
        ProviderRegistrationPage.txtbox_dob().sendKeys("04121987");
        Log.info("dob entered successfulylly");

        String password = ExcelUtils.getCellData(iTestCaseRow, Constant.Col_password);
        ProviderRegistrationPage.txtbox_password().sendKeys(password);
        Log.info("Entered password successfulylly");

        String confirmpassword = ExcelUtils.getCellData(iTestCaseRow, Constant.Col_confirmPassword);
        ProviderRegistrationPage.txtbox_confirmPassword().sendKeys(confirmpassword);
        Log.info("Entered confirm password successfulylly");

        ProviderRegistrationPage.button_registerProviderLink().click();

    } catch (Exception e) {
        throw (e);
    }
    Reporter.log("Registered for Provider successfully");

}

From source file:br.gov.frameworkdemoiselle.behave.runner.webdriver.ui.WebTextField.java

License:Open Source License

private String getValueToSend(String value) {
    String finalValue = Keys.chord(Keys.CONTROL, "a") + value + Keys.chord(Keys.TAB);
    return finalValue;
}

From source file:browsermator.com.NextTabAction.java

@Override
public void RunAction(WebDriver driver) {
    try {/*from   w  w w.  ja v a  2  s.  co m*/
        //       Actions actions = new Actions(driver);
        String current_tab_handle = driver.getWindowHandle();

        driver.findElement(By.cssSelector("body")).sendKeys(Keys.chord(Keys.CONTROL, Keys.TAB));
        // actions.keyDown(Keys.CONTROL).sendKeys(Keys.TAB).keyUp(Keys.CONTROL).build().perform();

        Set<String> tab_handles = driver.getWindowHandles();
        int current_tab_index = 0;

        int number_of_tabs = tab_handles.size();
        int tabs_counted = 1;
        for (String handle : tab_handles) {
            if (handle.equals(current_tab_handle)) {

                if (tabs_counted == number_of_tabs) {
                    // last tab
                    current_tab_index = 0;
                } else {
                    current_tab_index = tabs_counted;
                }
            }

            tabs_counted++;
        }

        driver.switchTo().window(tab_handles.toArray()[current_tab_index].toString());

        this.Pass = true;
    } catch (Exception ex) {
        this.Pass = false;
    }
}

From source file:com.actian.amc.pages.NewCloudDefinitionPage.java

public String getWarningMsgRequiredField(String Name) {
    driver.manage().timeouts().implicitlyWait(10, TimeUnit.SECONDS);

    try {//from www.  j  ava  2  s.co m
        switch (Name) {
        case "Cloud Name": {// Common to AWS, RackSpace, and Virtual Test Cloud
            driver.findElement(textField_CloudName).clear();
            driver.findElement(textField_CloudName).sendKeys(Keys.TAB);
            return getToolTipText();
        }
        case "Cloud Provider/API": // Common to AWS and RackSpace
        {
            driver.findElement(textField_CloudProvider).clear();
            driver.findElement(textField_CloudProvider).sendKeys(Keys.TAB);
            return getToolTipText();
        }
        case "Username": // Unique to RackSpace
        {
            driver.findElement(textField_RS_UserName).clear();
            driver.findElement(textField_RS_UserName).sendKeys(Keys.TAB);
            return getToolTipText();
        }
        case "API Key": // Unique to RackSpace
        {
            driver.findElement(textField_RS_APIKey).clear();
            driver.findElement(textField_RS_APIKey).sendKeys(Keys.TAB);
            return getToolTipText();
        }
        case "Access Key": // Unique to AWS
        {
            driver.findElement(textField_APIKey).clear();
            driver.findElement(textField_APIKey).sendKeys(Keys.TAB);
            return getToolTipText();
        }
        case "Secret Access Key": // Unique to AWS
        {
            driver.findElement(textField_SecretKey).clear();
            driver.findElement(textField_SecretKey).sendKeys(Keys.TAB);
            return getToolTipText();
        }
        case "Region Name": // Common to RackSpace only.
        {
            driver.findElement(textField_Region).clear();
            driver.findElement(textField_Region).sendKeys(Keys.TAB);
            return getToolTipText();
        }
        }
    } catch (NoSuchElementException | StaleElementReferenceException | IndexOutOfBoundsException e) {
        System.out.println("Trying to recover from a Exception(getWarningMsgRequiredField) :-");
    }
    return ("");
}

From source file:com.chtr.tmoauto.webui.CommonFunctions.java

License:Open Source License

/**
 * KEG notes works in chrome for add user
 * doesn't work for create bundle - drop down
 *//*from   w  w w .j a v  a  2s .c  om*/
@Override
public void focus(String locator) {
    findElement(locator).sendKeys(Keys.TAB);
}

From source file:com.googlecode.fightinglayoutbugs.DetectElementsWithInvisibleFocus.java

License:Apache License

@Nullable
private FocusedElement focusFirstElement(WebPage webPage) {
    WebElement firstFocusedWebElement = getFocusedWebElement(webPage);
    if (firstFocusedWebElement == null) {
        // Try to focus first element ...
        try {//from w w  w .j av  a  2 s.c  om
            WebDriver driver = webPage.getDriver();
            WebElement bodyElement = driver.findElement(By.tagName("body"));
            bodyElement.sendKeys(Keys.TAB);
        } catch (Exception e) {
            LOG.warn("Failed to focus first element.", e);
        }
        firstFocusedWebElement = getFocusedWebElement(webPage);
    } else if ("body".equals(firstFocusedWebElement.getTagName().toLowerCase())) {
        firstFocusedWebElement.sendKeys(Keys.TAB);
        firstFocusedWebElement = getFocusedWebElement(webPage);
    }
    if (firstFocusedWebElement != null && !"body".equals(firstFocusedWebElement.getTagName().toLowerCase())) {
        return toFocusedElement(firstFocusedWebElement, webPage);
    } else {
        return null;
    }
}

From source file:com.googlecode.fightinglayoutbugs.DetectElementsWithInvisibleFocus.java

License:Apache License

@Nullable
private FocusedElement focusNextElement(FocusedElement focusedElement, WebPage webPage,
        Collection<WebElement> visitedElements) {
    focusedElement.element.sendKeys(Keys.TAB);
    final WebElement focusedWebElement = getFocusedWebElement(webPage);
    if (focusedWebElement != null && !visitedElements.contains(focusedWebElement)
            && !"body".equals(focusedWebElement.getTagName().toLowerCase())) {
        visitedElements.add(focusedWebElement);
        return toFocusedElement(focusedWebElement, webPage);
    } else {/*from   w  w w  . j  av a 2s .  c  o m*/
        return null;
    }
}

From source file:com.hotwire.selenium.desktop.account.AccountPreferencesPage.java

License:Open Source License

public void addFavoriteAirport(String airportName) {
    // DO: Factor out clicking autocomplete in HotelSearchFragment to a generic place and
    // change the sendkeys below to use that method call when the autocomplete list for my
    // account is changed back to match in Prod/QA as QACI items do not save.
    favAirportInput.sendKeys(airportName + Keys.ESCAPE + Keys.TAB); // Do not choose from list.
    new WebDriverWait(getWebDriver(), DEFAULT_WAIT, SLEEP_INTERVAL_MILLIS)
            .until(PageObjectUtils.webElementVisibleTestFunction(autoCompleteContent, false));
    new WebDriverWait(getWebDriver(), DEFAULT_WAIT)
            .until(new IsElementLocationStable(getWebDriver(), By.xpath(SAVE_BUTTON)));
    saveChangesButton.click();/*from   w ww. j  av  a2 s.co  m*/
}

From source file:com.hotwire.selenium.desktop.hotelextranet.ExtranetChangePasswordPage.java

License:Open Source License

public void changePassword(String old_password, String new_password) {
    currentPassword.clear();//from   ww  w.  ja  va2s . com
    currentPassword.sendKeys(old_password);
    currentPassword.sendKeys(Keys.TAB);
    newPassword.clear();
    newPassword.sendKeys(new_password);
    newPassword.sendKeys(Keys.TAB);
    confirmNewPassword.clear();
    confirmNewPassword.sendKeys(new_password);
    changePasswordButton.click();
}