List of usage examples for org.openqa.selenium Keys RETURN
Keys RETURN
To view the source code for org.openqa.selenium Keys RETURN.
Click Source Link
From source file:at.tugraz.ist.catroweb.catroid.HeaderTests.java
License:Open Source License
@Test(groups = { "visibility" }, description = "check menu home button")
public void headerButtonsMobile() throws Throwable {
try {/*from www . ja va 2s .c o m*/
openMobileLocation();
assertTrue(isVisible(By.id("smallMenuBar")));
assertTrue(isVisible(By.xpath("//*[@id='smallMenuBar']/a")));
assertFalse(isVisible(By.id("smallSearchBar")));
assertTrue(isVisible(By.id("mobileSearchButton")));
assertTrue(isVisible(By.id("mobileMenuButton")));
assertTrue(isTextPresent(CommonStrings.NEWEST_PROJECTS_PAGE_TITLE.toUpperCase()));
driver().findElement(By.id("mobileMenuButton")).click();
assertRegExp(".*/login", driver().getCurrentUrl());
driver().findElement(By.xpath("//*[@id='smallMenuBar']/a")).click();
assertTrue(isTextPresent(CommonStrings.NEWEST_PROJECTS_PAGE_TITLE.toUpperCase()));
driver().findElement(By.id("mobileSearchButton")).click();
assertTrue(isVisible(By.id("smallSearchBar")));
driver().findElement(By.id("mobileSearchButton")).click();
assertFalse(isVisible(By.id("smallSearchBar")));
driver().findElement(By.id("mobileSearchButton")).click();
driver().findElement(By.xpath("//*[@id='smallSearchBar']/input")).sendKeys("test");
driver().findElement(By.xpath("//*[@id='smallSearchBar']/input")).sendKeys(Keys.RETURN);
assertRegExp(".*/search/.*", driver().getCurrentUrl());
driver().findElement(By.id("mobileMenuButton")).click();
driver().findElement(By.id("loginUsername")).sendKeys(CommonData.getLoginUserDefault());
driver().findElement(By.id("loginPassword")).sendKeys(CommonData.getLoginPasswordDefault());
driver().findElement(By.id("loginSubmitButton")).click();
ajaxWait();
driver().findElement(By.id("mobileMenuButton")).click();
assertTrue(isVisible(By.id("menuProfileButton")));
assertTrue(isVisible(By.id("menuLogoutButton")));
driver().findElement(By.id("menuProfileButton")).click();
assertTrue(containsElementText(By.xpath("//*[@id='wrapper']/article/header"),
CommonData.getLoginUserDefault().toUpperCase()));
driver().findElement(By.id("mobileMenuButton")).click();
driver().findElement(By.id("menuLogoutButton")).click();
driver().findElement(By.id("mobileMenuButton")).click();
ajaxWait();
assertTrue(containsElementText(By.xpath("//*[@id='wrapper']/article/div[1]"), "Login".toUpperCase()));
} catch (AssertionError e) {
captureScreen("HeaderTests.headerButtonsMobile");
throw e;
} catch (Exception e) {
captureScreen("HeaderTests.headerButtonsMobile");
throw e;
}
}
From source file:at.tugraz.ist.catroweb.catroid.SearchTests.java
License:Open Source License
@Test(groups = { "functionality" }, description = "checks all search boxes and buttons")
public void searchBoxesAndButton() throws Throwable {
try {//from ww w. j a va 2 s . c o m
String projectTitleA = "searchFunctionalityA" + CommonData.getRandomShortString(22);
projectUploader.upload(CommonData.getUploadPayload(projectTitleA, CommonData.getRandomLongString(200),
"", "", "", "", "", ""));
String projectTitleB = "searchFunctionalityA" + CommonData.getRandomShortString(22);
projectUploader.upload(CommonData.getUploadPayload(projectTitleB, CommonData.getRandomLongString(200),
"", "", "", "", "", ""));
By largeTopSearchBox = By.xpath("//*[@id='largeMenu']/div[4]/input");
By largeFooterSearchBox = By.xpath("//*[@id='largeFooterMenu']/div[2]/span[2]/input");
By mobileSearchBox = By.xpath("//*[@id='smallSearchBar']/input");
// large layout search bar on the top
openLocation();
assertTrue(isVisible(By.id("largeSearchButton")));
assertTrue(isVisible(largeTopSearchBox));
driver().findElement(largeTopSearchBox).sendKeys(projectTitleA);
driver().findElement(largeTopSearchBox).sendKeys(Keys.RETURN);
ajaxWait();
assertTrue(isElementPresent(By.xpath("//a[@title=\"" + projectTitleA + "\"]")));
assertFalse(isElementPresent(By.xpath("//a[@title=\"" + projectTitleB + "\"]")));
driver().findElement(largeTopSearchBox).clear();
driver().findElement(largeTopSearchBox).sendKeys(projectTitleB);
driver().findElement(largeTopSearchBox).sendKeys(Keys.RETURN);
ajaxWait();
assertFalse(isElementPresent(By.xpath("//a[@title=\"" + projectTitleA + "\"]")));
assertTrue(isElementPresent(By.xpath("//a[@title=\"" + projectTitleB + "\"]")));
openLocation();
driver().findElement(largeTopSearchBox).sendKeys(projectTitleA);
driver().findElement(By.id("largeSearchButton")).click();
ajaxWait();
assertTrue(isElementPresent(By.xpath("//a[@title=\"" + projectTitleA + "\"]")));
driver().findElement(largeTopSearchBox).clear();
driver().findElement(largeTopSearchBox).sendKeys(projectTitleB);
driver().findElement(By.id("largeSearchButton")).click();
ajaxWait();
assertFalse(isElementPresent(By.xpath("//a[@title=\"" + projectTitleA + "\"]")));
assertTrue(isElementPresent(By.xpath("//a[@title=\"" + projectTitleB + "\"]")));
// large layout search bar on the bottom
openLocation();
assertTrue(isVisible(By.id("footerSearchButton")));
assertTrue(isVisible(largeFooterSearchBox));
driver().findElement(largeFooterSearchBox).sendKeys(projectTitleA);
driver().findElement(largeFooterSearchBox).sendKeys(Keys.RETURN);
ajaxWait();
assertTrue(isElementPresent(By.xpath("//a[@title=\"" + projectTitleA + "\"]")));
assertFalse(isElementPresent(By.xpath("//a[@title=\"" + projectTitleB + "\"]")));
driver().findElement(largeFooterSearchBox).clear();
driver().findElement(largeFooterSearchBox).sendKeys(projectTitleB);
driver().findElement(largeFooterSearchBox).sendKeys(Keys.RETURN);
ajaxWait();
assertFalse(isElementPresent(By.xpath("//a[@title=\"" + projectTitleA + "\"]")));
assertTrue(isElementPresent(By.xpath("//a[@title=\"" + projectTitleB + "\"]")));
openLocation();
driver().findElement(largeFooterSearchBox).sendKeys(projectTitleA);
driver().findElement(By.id("footerSearchButton")).click();
ajaxWait();
assertTrue(isElementPresent(By.xpath("//a[@title=\"" + projectTitleA + "\"]")));
driver().findElement(largeFooterSearchBox).clear();
driver().findElement(largeFooterSearchBox).sendKeys(projectTitleB);
driver().findElement(By.id("footerSearchButton")).click();
ajaxWait();
assertFalse(isElementPresent(By.xpath("//a[@title=\"" + projectTitleA + "\"]")));
assertTrue(isElementPresent(By.xpath("//a[@title=\"" + projectTitleB + "\"]")));
// mobile layout search bar on the top
openMobileLocation();
assertTrue(isVisible(By.id("mobileSearchButton")));
assertFalse(isVisible(mobileSearchBox));
driver().findElement(By.id("mobileSearchButton")).click();
driver().findElement(mobileSearchBox).sendKeys(projectTitleA);
driver().findElement(mobileSearchBox).sendKeys(Keys.RETURN);
ajaxWait();
assertTrue(isElementPresent(By.xpath("//a[@title=\"" + projectTitleA + "\"]")));
assertFalse(isElementPresent(By.xpath("//a[@title=\"" + projectTitleB + "\"]")));
driver().findElement(mobileSearchBox).clear();
driver().findElement(mobileSearchBox).sendKeys(projectTitleB);
driver().findElement(mobileSearchBox).sendKeys(Keys.RETURN);
ajaxWait();
assertFalse(isElementPresent(By.xpath("//a[@title=\"" + projectTitleA + "\"]")));
assertTrue(isElementPresent(By.xpath("//a[@title=\"" + projectTitleB + "\"]")));
} catch (AssertionError e) {
captureScreen("SearchTests.searchBoxesAndButton");
throw e;
} catch (Exception e) {
captureScreen("SearchTests.searchBoxesAndButton");
throw e;
}
}
From source file:at.tugraz.ist.cucumber.SeleniumStepdefs.java
License:Open Source License
@When("^I use the top search box to search for a project called \"([^\"]*)\"$") public void I_use_the_top_search_box_to_search_for_a_project_called(String projectName) throws Throwable { WebElement largeTopSearchBox = driver().findElement(By.xpath("//*[@id='largeMenu']/div[4]/input")); WebElement mobileSearchBox = driver().findElement(By.xpath("//*[@id='smallSearchBar']/input")); WebElement mobileSearchButton = driver().findElement(By.id("mobileSearchButton")); if (largeTopSearchBox.isDisplayed()) { largeTopSearchBox.clear();//www. ja va 2 s.c o m largeTopSearchBox.sendKeys(projectName); largeTopSearchBox.sendKeys(Keys.RETURN); jqueryWait(); } else if (mobileSearchButton.isDisplayed()) { mobileSearchButton.click(); mobileSearchBox.clear(); mobileSearchBox.sendKeys(projectName); mobileSearchBox.sendKeys(Keys.RETURN); jqueryWait(); } }
From source file:browsermator.com.EnterKeyAction.java
@Override public void RunAction(WebDriver driver) { try {//from w w w. jav a 2 s .c o m WebElement element = driver.switchTo().activeElement(); element.sendKeys(Keys.RETURN); this.Pass = true; } catch (Exception ex) { this.Pass = false; } }
From source file:cc.kune.selenium.login.LoginPageObject.java
License:GNU Affero Public License
/** * Fill sig in in form./*from w w w .jav a 2 s . co m*/ * * @param username * the username * @param password * the password * @param withReturn * the with return */ public void fillSigInInForm(final String username, final String password, final boolean withReturn) { clearField(user); hightlight(user); user.sendKeys(username); clearField(passwd); hightlight(passwd); passwd.sendKeys(password); // hightlight(signInButton); if (withReturn) { passwd.sendKeys(Keys.RETURN); } else { signInButton.click(); } }
From source file:cc.kune.selenium.login.RegisterPageObject.java
License:GNU Affero Public License
/** * Fill register form./*from w w w . j ava2s .c om*/ * * @param nick * the nick * @param name * the name * @param pass * the pass * @param em * the em * @param withReturn * the with return * @param doScreenshot * the do screenshot */ public void fillRegisterForm(final String nick, final String name, final String pass, final String em, final boolean withReturn, final boolean doScreenshot) { clearField(shortName); hightlight(shortName); shortName.sendKeys(nick); clearField(longName); hightlight(longName); longName.sendKeys(name); clearField(passwd); hightlight(passwd); passwd.sendKeys(pass); clearField(email); hightlight(email); email.sendKeys(em); hightlight(registerButton); if (doScreenshot) { SeleniumUtils.doScreenshot(getWebDriver(), "register"); sleep(2000); } if (withReturn) { email.sendKeys(Keys.RETURN); } else { registerButton.click(); } }
From source file:com.cognifide.qa.bb.aem.dialog.classic.field.tags.AemTags.java
License:Apache License
private void waitUntilTagCreated(final int tagsCount) { bobcatWait.withTimeout(Timeouts.BIG).until(driver -> { input.sendKeys(Keys.RETURN); return getTagCount() == tagsCount + 1; }, 2);//from w w w. j a v a 2 s . c o m }
From source file:com.ecofactor.qa.automation.util.mail.OutlookMail.java
License:Open Source License
/** * Gets the changed password./*from w w w .j ava2 s . com*/ * @param driver the driver * @param url the url * @param emailUserName the email user name * @param emailPassword the email password * @param subject the subject * @param boldIndex the bold index * @return the changed password */ public String getChangedPassword(String url, String emailUserName, String emailPassword, String subject, int boldIndex) { WebDriver driver = driverConfig.getDriver(); DriverConfig.setLogString("Load Email portal URL.", true); driver.navigate().to(url); largeWait(); DriverConfig.setLogString("Enter Username/Password for Email.", true); driver.findElement(By.id("cred_userid_inputtext")).sendKeys(emailUserName); driver.findElement(By.id("cred_password_inputtext")).sendKeys(emailPassword); smallWait(); DriverConfig.setLogString("Click Login.", true); WebElement signInButtonElement = driver.findElement(By.cssSelector("#cred_sign_in_button")); DriverConfig.setLogString("send keys to login", true); signInButtonElement.sendKeys(Keys.RETURN); largeWait(); DriverConfig.setLogString("click btn", true); signInButtonElement.click(); largeWait(); DriverConfig.setLogString("Click Inbox.", true); WebElement outLookMenu = retrieveElementByTagText(driver, TAG_SPAN, "Outlook"); if (outLookMenu != null && outLookMenu.isDisplayed()) { outLookMenu.click(); mediumWait(); } DriverConfig.setLogString("Click Subject of Email.", true); List<WebElement> subElements = retrieveElementsByTagText(driver, TAG_SPAN, subject); if (subElements.size() > 0) { subElements.get(0).click(); mediumWait(); } largeWait(); DriverConfig.setLogString("Get temporary Password from Email.", true); WebElement divBodyElement = driver.findElement(By.id("Item.MessagePartBody")); mediumWait(); WebElement pwdElement = divBodyElement.findElements(By.tagName(TAG_BOLD)).get(boldIndex); String tempPassword = pwdElement.getText(); DriverConfig.setLogString("Temporary password got from email " + tempPassword, true); DriverConfig.setLogString("Click user for Signout option", true); WebElement menuElement = retrieveElementByAttributeValue(driver, TAG_BUTTON, ATTR_CLASS, "button _hl_2 _hl_e"); menuElement.click(); smallWait(); DriverConfig.setLogString("Click Signout", true); WebElement signOut = retrieveElementByTagText(driver, TAG_SPAN, "sign out", MEDIUM_TIMEOUT); signOut.click(); smallWait(); return tempPassword; }
From source file:com.gargoylesoftware.htmlunit.javascript.host.event.KeyboardEventTest.java
License:Apache License
/** * @throws Exception if the test fails/*from ww w . j a v a2s . c o m*/ */ @Test @Alerts(DEFAULT = { "keydown:16,0,16", "keydown:65,0,65", "keypress:65,65,65", "keyup:65,0,65", "keyup:16,0,16", "keydown:65,0,65", "keypress:97,97,97", "keyup:65,0,65", "keydown:190,0,190", "keypress:46,46,46", "keyup:190,0,190", "keydown:13,0,13", "keypress:13,13,13", "keyup:13,0,13" }, FF = { "keydown:16,0,16", "keydown:65,0,65", "keypress:0,65,65", "keyup:65,0,65", "keyup:16,0,16", "keydown:65,0,65", "keypress:0,97,97", "keyup:65,0,65", "keydown:190,0,190", "keypress:0,46,46", "keyup:190,0,190", "keydown:13,0,13", "keypress:13,0,13", "keyup:13,0,13" }) public void which() throws Exception { final String html = "<html><head></head><body>\n" + "<input type='text' id='keyId'>\n" + "<script>\n" + "function handler(e) {\n" + " e = e ? e : window.event;\n" + " document.getElementById('myTextarea').value " + "+= e.type + ':' + e.keyCode + ',' + e.charCode + ',' + e.which + '\\n';\n" + "}\n" + "document.getElementById('keyId').onkeyup = handler;\n" + "document.getElementById('keyId').onkeydown = handler;\n" + "document.getElementById('keyId').onkeypress = handler;\n" + "</script>\n" + "<textarea id='myTextarea' cols=80 rows=20></textarea>\n" + "</body></html>"; final String keysToSend = "Aa." + Keys.RETURN; final WebDriver driver = loadPage2(html); driver.findElement(By.id("keyId")).sendKeys(keysToSend); final String[] actual = driver.findElement(By.id("myTextarea")).getAttribute("value").split("\r\n|\n"); assertEquals(Arrays.asList(getExpectedAlerts()).toString(), Arrays.asList(actual).toString()); }
From source file:com.itson.servicedesigncenter.SdcPages.java
License:Open Source License
public SdcPages setSubscriberGroupPhoneNumber(String value) { browser.logAction("Inputing PhoneNumber: " + value); browser.click(subscriberGroupMatcherPhoneNumber); subscriberGroupPhoneNumber = value;//from ww w . ja va 2 s .c o m subscriberGroupMatcherPhoneNumber.sendKeys(subscriberGroupPhoneNumber, Keys.RETURN); return this; }