List of usage examples for org.openqa.selenium WebElement sendKeys
void sendKeys(CharSequence... keysToSend);
From source file:com.hotwire.selenium.tools.c3.purchase.car.C3CarBillingPage.java
License:Open Source License
public void fillCreditCard(String creditCardNumber, String creditCardExpMonth, String creditCardExpYear, String creditCardSecurityCode) { setText("input[name='billingForm.paymentForm._NAE_acctNumber']", creditCardNumber); selectValue("select[name='billingForm.paymentForm.cardMonth']", creditCardExpMonth); selectValue("select[name='billingForm.paymentForm.cardYear']", creditCardExpYear); for (WebElement securityCodeField : findMany("input[name='billingForm.paymentForm._NAE_cpvNumber']")) { if (securityCodeField.isDisplayed()) { securityCodeField.sendKeys(creditCardSecurityCode); }//ww w. j av a 2 s. co m } }
From source file:com.hotwire.selenium.tools.c3.refund.C3ServiceRecoveryPage.java
License:Open Source License
public void answerMinorBookingQuestions() { List<WebElement> questions = findMany("div#questions input"); for (WebElement question : questions) { question.sendKeys("Test"); }/* ww w . j a v a2s .c o m*/ answerQuestion(3, "No"); }
From source file:com.hotwire.selenium.tools.travelAdvisory.TravelAdvisoryUpdatesPage.java
License:Open Source License
private void setIssueField(String fieldName, String text) { final WebElement webElement = findMany(By.name(fieldName)).get(index); webElement.clear();/*from www. j a v a2 s . com*/ webElement.sendKeys(text); }
From source file:com.htmlhifive.test.selenium.testcase.coverage.BrowserCheckTest.java
License:Apache License
@Test public void showBrowserCheckPage() throws InterruptedException { WebElement locationBox = querySelector("#location").get(0); locationBox.clear();//from w ww . j a v a 2s .com locationBox.sendKeys("http://localhost:8080/htmlhifiveWeb/coverage/webdriver/sandboxInternal/coverage/"); WebElement openInFrame = querySelector("[title='open URL in the iframe below [Enter]']").get(0); openInFrame.click(); Thread.sleep(100); getDriver().switchTo().defaultContent(); Thread.sleep(100); }
From source file:com.htmlhifive.test.selenium.testcase.coverage.IndicatorTest.java
License:Apache License
public IndicatorTest(WebDriver driver) throws InterruptedException { super(driver); try {//from ww w .j av a 2 s. c om if (querySelector("#location").get(0).getText().equals(BLOCK_SAMPLE_PAGE)) { return; } } catch (Exception e) { return; } // ???BeforeClass??????????????????? WebElement locationBox = querySelector("#location").get(0); locationBox.clear(); locationBox.sendKeys(BLOCK_SAMPLE_PAGE); WebElement openInWindow = querySelector("[title='open URL in the iframe below [Enter]']").get(0); openInWindow.click(); Thread.sleep(1000); }
From source file:com.htmlhifive.test.selenium.testcase.coverage.marge.Runner.java
License:Apache License
@Test public void openQUnit() throws InterruptedException { WebElement locationBox = querySelector("#location").get(0); locationBox.clear();/*from ww w . j av a 2 s .co m*/ locationBox.sendKeys(QUNIT_PAGE); WebElement openInWindow = querySelector("[title='open URL in the iframe below [Enter]']").get(0); openInWindow.click(); Thread.sleep(1000); }
From source file:com.ibm.sbt.automation.core.environment.TestEnvironment.java
License:Open Source License
protected void handleBasicLogin(BaseTest baseTest) { String loginFormId = baseTest.getProperty(PROP_BASIC_LOGINFORMID); String usernameId = baseTest.getProperty(PROP_BASIC_USERNAMEID); String passwordId = baseTest.getProperty(PROP_BASIC_PASSWORDID); String submitId = baseTest.getProperty(PROP_BASIC_SUBMITID); String username = null;//w w w. j ava2 s . c o m String password = null; if (isSmartCloud()) { username = baseTest.getProperty(PROP_OAUTH10_USERNAME); password = baseTest.getProperty(PROP_OAUTH10_PASSWORD); } else { username = baseTest.getProperty(PROP_BASIC_USERNAME); password = baseTest.getProperty(PROP_BASIC_PASSWORD); } WebElement loginForm = waitForLoginForm(loginTimeout, loginFormId, null, BasicLoginTitle, baseTest); if (baseTest.isResultsReady()) return; if (loginForm != null) { WebElement usernameEl = loginForm.findElement(By.name(usernameId)); WebElement passwordEl = loginForm.findElement(By.name(passwordId)); WebElement submitEl = loginForm.findElement(By.name(submitId)); usernameEl.sendKeys(username); passwordEl.sendKeys(password); submitEl.click(); } else { // check if page was authenticated before if (baseTest.waitForResult(0) != null) return; fail("Unable to locate basic login form"); } }
From source file:com.ibm.sbt.automation.core.environment.TestEnvironment.java
License:Open Source License
protected void handleOAuth10(BaseTest baseTest) { String loginFormId = baseTest.getProperty(PROP_OAUTH10_LOGINFORMID); String usernameId = baseTest.getProperty(PROP_OAUTH10_USERNAMEID); String passwordId = baseTest.getProperty(PROP_OAUTH10_PASSWORDID); String submitId = baseTest.getProperty(PROP_OAUTH10_SUBMITID); String username = baseTest.getProperty(PROP_OAUTH10_USERNAME); String password = baseTest.getProperty(PROP_OAUTH10_PASSWORD); WebElement loginForm = waitForLoginForm(loginTimeout, loginFormId, null, OAuth10LoginTitle, baseTest); if (baseTest.isResultsReady()) return;//from w ww.j a v a2 s.c om if (loginForm != null) { WebElement continueButton = loginForm.findElement(By.id("continue")); WebElement usernameEl = loginForm.findElement(By.name(usernameId)); WebElement passwordEl = loginForm.findElement(By.name(passwordId)); WebElement submitEl = loginForm.findElements(By.id(submitId)).get(0); usernameEl.sendKeys(username); if (continueButton != null) { continueButton.click(); WebDriverWait wait = new WebDriverWait(webDriver, 10); WebElement element = wait.until(ExpectedConditions.visibilityOfElementLocated(By.id(submitId))); } passwordEl.sendKeys(password); submitEl.click(); } else { fail("Unable to locate OAuth1.0 login form"); } }
From source file:com.ibm.sbt.automation.core.environment.TestEnvironment.java
License:Open Source License
protected void handleOAuth20(BaseTest baseTest) { String loginFormXPath = baseTest.getProperty(PROP_OAUTH20_LOGINFORMXPATH); String usernameXPath = baseTest.getProperty(PROP_OAUTH20_USERNAMEXPATH); String passwordXPath = baseTest.getProperty(PROP_OAUTH20_PASSWORDXPATH); String submitXPath = baseTest.getProperty(PROP_OAUTH20_SUBMITXPATH); String grantXPath = baseTest.getProperty(PROP_OAUTH20_GRANTXPATH); String username = baseTest.getProperty(PROP_OAUTH20_USERNAME); String password = baseTest.getProperty(PROP_OAUTH20_PASSWORD); WebElement loginForm = waitForLoginForm(loginTimeout, null, loginFormXPath, OAuth20LoginTitle, baseTest); if (baseTest.isResultsReady()) return;// w w w .jav a 2 s . com if (loginForm != null) { WebElement usernameEl = loginForm.findElement(By.xpath(usernameXPath)); WebElement passwordEl = loginForm.findElement(By.xpath(passwordXPath)); WebElement submitEl = loginForm.findElements(By.xpath(submitXPath)).get(0); usernameEl.sendKeys(username); passwordEl.sendKeys(password); submitEl.click(); // wait for authorization popup WebElement authPage = waitForPopup(loginTimeout, OAuth20AuthTitle); if (authPage != null) { WebElement grantEl = authPage.findElement(By.xpath(grantXPath)); grantEl.click(); } else { fail("Unable to locate OAuth2.0 authorization page"); } } else { fail("Unable to locate OAuth2.0 login form"); } }
From source file:com.ibm.watson.app.qaclassifier.selenium.MenuIT.java
License:Open Source License
@Test public void closeMenuOverlayWithEscapeKey() { WebElement menuIconContainer = driver.findElement(By.id("menuIconContainerDesktop")); WebElement menuIconImg = menuIconContainer .findElement(By.xpath(".//span[contains(concat(' ', @class, ' '), ' menuIconImg ')]")); menuIconImg.click();/*from w w w . j a va 2 s . co m*/ WebElement menuList = driver.findElement(By.className("menu-list")); List<WebElement> menuOptions = menuList.findElements(By.xpath(".//ul/li")); // The first item should be home, which is hidden on Desktop, so skip it and do the second one WebElement firstMenuOption = menuOptions.get(2); firstMenuOption.click(); // Press ESC to close overlay WebElement menuOverlay = driver.findElement(By.id("menuOverlay")); menuOverlay.sendKeys(Keys.ESCAPE); assertTrue("Hitting the ESC key closes the menu overlay", driver.findElements(By.id("menuOverlay")).size() == 0); }