Example usage for org.openqa.selenium Keys RETURN

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

Introduction

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

Prototype

Keys RETURN

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

Click Source Link

Usage

From source file:org.craftercms.cstudio.share.selenium.basic.SearchTest.java

License:Open Source License

private void test_search(WebDriver driver) {
    // Login//from  w  w w  .  j  av  a2  s .  co  m
    CStudioSeleniumUtil.try_login(driver, CStudioSeleniumUtil.ADMIN_USER, CStudioSeleniumUtil.ADMIN_PASSWORD,
            true);

    // Navigate to Dashboard
    CStudioSeleniumUtil.navigate_to_dashboard(driver);

    // Edit 'index' page
    CStudioSeleniumUtil.edit_index_page(driver);

    // Switch to 'Entry' window
    CStudioSeleniumUtil.switch_to_window(driver, "Entry");

    // Change title
    WebElement element = driver
            .findElement(By.id("accordion$pageSettings$internalTitle$input-counted$xforms-input-1"));
    element.clear();
    element.sendKeys("Acme Home - XYZ123");

    // Save changes
    CStudioSeleniumUtil.click_on(driver, By.id("formSaveButton"));

    // Switch to 'Crafter Studio' window
    CStudioSeleniumUtil.switch_to_window(driver, "Crafter Studio");

    element = driver.findElement(By.id("acn-searchtext"));
    element.clear();
    element.sendKeys("XYZ123");
    element.sendKeys(Keys.RETURN);
    CStudioSeleniumUtil.wait_until_displayed(driver, CStudioSeleniumUtil.LONG_TIMEOUT,
            By.id("result-select--site-website-index-xml"));

    element = driver.findElement(By.id("acn-searchtext"));
    element.clear();
    element.sendKeys("rewrwr3445wdq23423423qfw");
    element.sendKeys(Keys.RETURN);

    new WebDriverWait(driver, CStudioSeleniumUtil.LONG_TIMEOUT).until(new ExpectedCondition<Boolean>() {
        public Boolean apply(WebDriver d) {
            return d.findElement(By.tagName("body")).getText().contains("Your search returned no results.");
        }
    });

    // Close driver
    CStudioSeleniumUtil.exit(driver);
}

From source file:org.jboss.seam.example.remoting.chatroom.test.webdriver.WebDriverChatroomTest.java

License:Open Source License

public void connect() {

    driver.findElement(NAME_INPUT).clearAndSendKeys(NAME1, Keys.TAB);

    driver.setWaitTime(timeout);//from  w  ww .  j  a  va2s. c  o  m

    //more reliable than simple click
    driver.findElement(CONNECT_BUTTON).clearAndSendKeys(Keys.RETURN);

    try {
        Thread.sleep(timeout);
    } catch (InterruptedException e) {
    }
}

From source file:org.jboss.seam.example.remoting.chatroom.test.webdriver.WebDriverChatroomTest.java

License:Open Source License

public void chat() {
    /*first user is sending a message*/
    driver.findElement(MESSAGE_INPUT).clearAndSendKeys(MESSAGE_FROM_MARTIN);
    driver.findElement(MESSAGE_INPUT).sendKeys(Keys.RETURN);

    try {//w  w w  . ja v a  2s.  c  o  m
        Thread.sleep(timeout);
    } catch (InterruptedException e) {
    }

    driver.findElement(MARTIN_GT);
    driver.findElement(HELLO);
    driver2.findElement(MARTIN_GT);
    driver2.findElement(HELLO);
    driver2.findElement(MESSAGE_INPUT).clearAndSendKeys(MESSAGE_FROM_JOZEF, Keys.RETURN);

    try {
        Thread.sleep(timeout);
    } catch (InterruptedException e) {
    }

    driver2.findElement(JOZEF_GT);
    driver2.findElement(GOOD_MORNING);
    driver.findElement(JOZEF_GT);
    driver.findElement(GOOD_MORNING);
}

From source file:org.jitsi.meet.test.DisplayNameTest.java

License:Apache License

/**
 * Changes the display name./*from   w ww.  j a va2  s. co  m*/
 * @param newName the name to change.
 */
private void changeDisplayName(String newName) {
    System.err.println("Start changeDisplayName for " + newName + ".");

    WebDriver secondParticipant = ConferenceFixture.getSecondParticipant();

    WebElement elem = secondParticipant
            .findElement(By.xpath("//span[@id='localVideoContainer']" + "//span[@id='localDisplayName']"));
    // hover the element before clicking
    Actions action0 = new Actions(secondParticipant);
    action0.moveToElement(elem);
    action0.perform();

    elem.click();

    WebElement inputElem = secondParticipant
            .findElement(By.xpath("//span[@id='localVideoContainer']" + "//input[@id='editDisplayName']"));
    Actions action = new Actions(secondParticipant);
    action.moveToElement(inputElem);
    action.perform();

    if (newName != null && newName.length() > 0)
        inputElem.sendKeys(newName);
    else
        inputElem.sendKeys(Keys.BACK_SPACE);

    inputElem.sendKeys(Keys.RETURN);
    // just click somewhere to lose focus, to make sure editing has ended
    String ownerResource = MeetUtils.getResourceJid(ConferenceFixture.getOwner());
    MeetUIUtils.clickOnRemoteVideo(secondParticipant, ownerResource);
    MeetUIUtils.clickOnRemoteVideo(secondParticipant, ownerResource);
}

From source file:org.jitsi.meet.test.pageobjects.web.InfoDialog.java

License:Apache License

/**
 * Sets a password on the current conference to lock it.
 *
 * @param password - The password to use to lock the conference.
 *//*from   ww  w. ja v a 2 s  .  c o m*/
public void addPassword(String password) {
    WebDriver driver = participant.getDriver();

    open();

    driver.findElement(By.className(ADD_PASSWORD_LINK)).click();

    TestUtils.waitForElementBy(driver, By.className(ADD_PASSWORD_FIELD), 5);
    WebElement passwordEntry = driver.findElement(By.className(ADD_PASSWORD_FIELD));

    passwordEntry.sendKeys(password);
    passwordEntry.sendKeys(Keys.RETURN);
}

From source file:org.jitsi.meet.test.web.WebParticipant.java

License:Apache License

/**
 * {@inheritDoc}/*from   ww  w . j a v  a  2 s .co m*/
 */
@Override
public void setDisplayName(String name) {
    WebDriver driver = getDriver();

    WebElement elem = driver
            .findElement(By.xpath("//span[@id='localVideoContainer']" + "//span[@id='localDisplayName']"));
    // hover the element before clicking
    Actions actions = new Actions(driver);
    actions.moveToElement(elem);
    actions.perform();

    elem.click();

    WebElement inputElem = driver
            .findElement(By.xpath("//span[@id='localVideoContainer']" + "//input[@id='editDisplayName']"));
    actions = new Actions(driver);
    actions.moveToElement(inputElem);
    actions.perform();

    if (name != null && name.length() > 0) {
        inputElem.sendKeys(name);
    } else {
        inputElem.sendKeys(Keys.BACK_SPACE);
    }

    inputElem.sendKeys(Keys.RETURN);
    // just click somewhere to lose focus, to make sure editing has ended
    MeetUIUtils.clickOnLocalVideo(driver);
}

From source file:org.jspringbot.keyword.selenium.SeleniumHelper.java

License:Open Source License

private String mapAsciiKeyCodeToKey(int keyCode) {
    Map<Integer, Keys> keysMap = new HashMap<Integer, Keys>();
    keysMap.put(0, Keys.NULL);//from w  w w.j ava 2s .  com
    keysMap.put(8, Keys.BACK_SPACE);
    keysMap.put(9, Keys.TAB);
    keysMap.put(10, Keys.RETURN);
    keysMap.put(13, Keys.ENTER);
    keysMap.put(24, Keys.CANCEL);
    keysMap.put(27, Keys.ESCAPE);
    keysMap.put(32, Keys.SPACE);
    keysMap.put(42, Keys.MULTIPLY);
    keysMap.put(43, Keys.ADD);
    keysMap.put(44, Keys.SUBTRACT);
    keysMap.put(56, Keys.DECIMAL);
    keysMap.put(57, Keys.DIVIDE);
    keysMap.put(59, Keys.SEMICOLON);
    keysMap.put(61, Keys.EQUALS);
    keysMap.put(127, Keys.DELETE);
    Keys key = keysMap.get(keyCode);

    if (key == null) {
        Character c = (char) keyCode;
        return c.toString();
    }

    return key.toString();
}

From source file:org.keycloak.testsuite.pages.social.BitbucketLoginPage.java

License:Apache License

@Override
public void login(String user, String password) {
    try {// w w  w. jav  a  2s .  co m
        clickLink(loginWithAtlassianButton); // BitBucket no longer has it's own login page yet sometimes it's
                                             // displayed even though we need to use the Atlassian login page
    } catch (NoSuchElementException e) {
        log.info("Already on Atlassian login page");
    }

    usernameInput.sendKeys(user);
    usernameInput.sendKeys(Keys.RETURN);
    pause(1000);

    passwordInput.sendKeys(password);
    passwordInput.sendKeys(Keys.RETURN);
}

From source file:org.keycloak.testsuite.pages.social.GitLabLoginPage.java

License:Apache License

@Override
public void login(String user, String password) {
    try {/* w  w  w  .  j  ava  2  s.c  om*/
        usernameInput.sendKeys(user);
        passwordInput.sendKeys(password);
        passwordInput.sendKeys(Keys.RETURN);
    } catch (NoSuchElementException e) {
        // already logged in
    }

    try {
        authorizeButton.click();
    } catch (NoSuchElementException e) {
        // might not be necessary
    }
}

From source file:org.keycloak.testsuite.pages.social.GoogleLoginPage.java

License:Apache License

@Override
public void login(String user, String password) {
    if (selectAccountLinks.size() > 1) {
        clickLink(selectAccountLinks.get(selectAccountLinks.size() - 1));
    }//w  w w . ja v  a  2 s  .c  o m

    emailInput.clear();
    emailInput.sendKeys(user);
    performOperationWithPageReload(() -> emailInput.sendKeys(Keys.RETURN));
    passwordInput.sendKeys(password);
    passwordInput.sendKeys(Keys.RETURN);
}