List of usage examples for org.openqa.selenium WebElement sendKeys
void sendKeys(CharSequence... keysToSend);
From source file:com.hotwire.selenium.desktop.widget.DropDownSelector.java
License:Open Source License
/** * Select item from drop-down by its visible text */// w w w . jav a2 s .c o m public void selectByVisibleText(String itemText) { if (StringUtils.isEmpty(itemText)) { return; } if (nativeDropDown.isDisplayed()) { Select startTimeCarSelect = new Select(nativeDropDown); startTimeCarSelect.selectByVisibleText(itemText); return; } By href = By.cssSelector(String.format("a[id^='%s']", nativeDropDown.getAttribute("id"))); new WebDriverWait(webDriver, TIMEOUT).until(ExpectedConditions.presenceOfAllElementsLocatedBy(href)); WebElement customDropDown = webDriver.findElement(href); customDropDown.click(); customDropDown.sendKeys(Keys.HOME); By elementSelector = By.xpath("//div[contains(@class,'ui-selectmenu-open')]//a[text()='" + itemText + "']"); WebElement element = webDriver.findElement(elementSelector); element.click(); }
From source file:com.hotwire.selenium.mobile.billing.AbstractPaymentMethodFragment.java
License:Open Source License
public AbstractPaymentMethodFragment setState(String state, String country) { boolean isSelect = true; WebElement element; if (country.equalsIgnoreCase("united states")) { element = this.state; } else if (country.equalsIgnoreCase("canada")) { element = getWebDriver().findElement(By.cssSelector("select[id='province']")); } else if (country.equalsIgnoreCase("australia")) { element = getWebDriver().findElement(By.cssSelector("select[id='auProvince']")); } else {//from ww w. j ava 2 s . c o m element = getWebDriver().findElement(By.cssSelector("input[id='other']")); isSelect = false; } if (!element.isDisplayed()) { return this; } if (!isSelect) { element.sendKeys(state); } else { if (element.isDisplayed()) { Select select = new Select(element); try { int index = Integer.parseInt(state); select.selectByIndex(index); } catch (NumberFormatException e) { select.selectByValue(state); } } } return this; }
From source file:com.hotwire.selenium.mobile.billing.AbstractPaymentMethodFragment.java
License:Open Source License
protected void submitData(String ccNumber, String ccExpMonth, String ccExpYear, String securityCode, String firstName, String lastName, String billingAddress, String country, String city, String state, String zipCode) {//from www. j a va 2s.c om new Select(this.country).selectByVisibleText(country); this.ccNumber.clear(); this.ccNumber.sendKeys(ccNumber); new Select(this.ccExpMonth).selectByVisibleText(ccExpMonth); new Select(this.ccExpYear).selectByVisibleText(ccExpYear); this.securityCode.clear(); this.securityCode.sendKeys(securityCode); this.firstName.clear(); this.firstName.sendKeys(firstName); this.lastName.clear(); this.lastName.sendKeys(lastName); if (this.billingAddress.isDisplayed()) { this.billingAddress.clear(); this.billingAddress.sendKeys(billingAddress); } if (this.city.isDisplayed()) { this.city.clear(); this.city.sendKeys(city); } WebElement element; boolean isSelect = true; if (country.equalsIgnoreCase("united states")) { element = this.state; } else if (country.equalsIgnoreCase("canada")) { element = getWebDriver().findElement(By.cssSelector("select[id='province']")); } else if (country.equalsIgnoreCase("australia")) { element = getWebDriver().findElement(By.cssSelector("select[id='auProvince']")); } else { element = getWebDriver().findElement(By.cssSelector("input[id='other']")); isSelect = false; } if (!isSelect) { element.sendKeys(state); } else { if (element.isDisplayed()) { Select select = new Select(element); try { int index = Integer.parseInt(state); select.selectByIndex(index); } catch (NumberFormatException e) { select.selectByValue(state); } } } this.zipCode.clear(); this.zipCode.sendKeys(zipCode); }
From source file:com.hotwire.selenium.tools.c3.customer.C3SearchCustomerPage.java
License:Open Source License
public void setEmailInput(String email) { LOGGER.info("Customer email:" + email); WebElement emailField = findOne("input#emailAddress", EXTRA_WAIT); emailField.sendKeys(email); waitForRedArrow();// w ww. j ava2s. co m }
From source file:com.hotwire.selenium.tools.c3.customer.C3SearchCustomerPage.java
License:Open Source License
public void setConfirmationNumber(String itin) { WebElement itineraryInput = findOne("input#confirmationNumber", EXTRA_WAIT); itineraryInput.sendKeys(itin); waitForRedArrow();/* www . j a va2s .c o m*/ itineraryInput.sendKeys(Keys.ENTER); }
From source file:com.hotwire.selenium.tools.c3.customer.C3SearchCustomerPage.java
License:Open Source License
private void searchCustomerBy(String cssLocator, String searchValue) { WebElement itineraryInput = findOne(cssLocator, EXTRA_WAIT); itineraryInput.sendKeys(searchValue); waitForRedArrow();// w ww . j a v a 2 s .c o m itineraryInput.sendKeys(Keys.ENTER); }
From source file:com.hotwire.selenium.tools.c3.customer.C3SearchPartnerPage.java
License:Open Source License
public void searchForItinerary(String itin) { WebElement itineraryInput = findOne("input[name='partnerConfirmationNumber']", EXTRA_WAIT); itineraryInput.sendKeys(itin); findOne("img[name='confirmationNumberGif']", DEFAULT_WAIT); itineraryInput.sendKeys(Keys.ENTER); }
From source file:com.hotwire.selenium.tools.c3.purchase.air.billing.C3AirMultiPassengerInfoFragment.java
License:Open Source License
public C3AirMultiPassengerInfoFragment fillGuestName() { for (WebElement name : findMany("div#travelers div.name input")) { if (name.isDisplayed()) { name.sendKeys("Test" + RandomStringUtils.randomAlphabetic(5)); }/*from ww w. jav a 2 s. c o m*/ } return this; }
From source file:com.hotwire.selenium.tools.c3.purchase.air.billing.C3AirMultiPassengerInfoFragment.java
License:Open Source License
public C3AirMultiPassengerInfoFragment fillCustomerName() { List<WebElement> travelerName; try {//from ww w. j a va 2 s .co m travelerName = findMany(By.xpath("//input[contains(@name, 'travelerForm.psgrFirstName')]")); for (WebElement name : travelerName) { name.sendKeys("FirstName" + RandomStringUtils.randomAlphabetic(3)); } } catch (Exception e) { logger.info("Travelers first name pre-filled"); } try { travelerName = findMany(By.xpath("//input[contains(@name, 'travelerForm.psgrLastName')]")); for (WebElement name : travelerName) { name.sendKeys("LastName" + RandomStringUtils.randomAlphabetic(3)); } } catch (Exception e) { logger.info("Travelers last name pre-filled"); } return this; }
From source file:com.hotwire.selenium.tools.c3.purchase.air.billing.C3AirMultiPassengerInfoFragment.java
License:Open Source License
/** * Fill email and confirmation email//from w ww .j a va 2 s. c o m */ public C3AirMultiPassengerInfoFragment fillEmails(String email) { for (WebElement emailField : findMany("input.email")) { if (emailField.isDisplayed()) { emailField.sendKeys(email); } } return this; }