List of usage examples for org.openqa.selenium WebElement getAttribute
String getAttribute(String name);
From source file:com.hotwire.selenium.desktop.globalheader.GlobalHeader.java
License:Open Source License
public void changeCurrency(String currency) { openCurrencyDropdown();//from www . j a v a 2 s . c o m new WebDriverWait(getWebDriver(), DEFAULT_WAIT).until(new IsElementLocationStable(getWebDriver(), By.cssSelector(SELECT_CURRENCY_DROPDOWN + " ul"), DEFAULT_ITERATIONS)); List<WebElement> elements = selectCurrencyDropdown.findElements(By.cssSelector(" li a")); boolean found = false; for (WebElement element : elements) { if (element.getAttribute("data-currencycode").toLowerCase().trim() .equals(currency.toLowerCase().trim())) { found = true; element.click(); break; } } if (!found) { throw new RuntimeException(currency + " not found in currency selection list."); } }
From source file:com.hotwire.selenium.desktop.globalheader.GlobalHeader.java
License:Open Source License
public Collection<String> getSupportedCurrencies() { Collection<String> currencies = new HashSet<String>(); openCurrencyDropdown();/*from w w w . j a v a 2s. c o m*/ new WebDriverWait(getWebDriver(), DEFAULT_WAIT).until(new IsElementLocationStable(getWebDriver(), By.cssSelector(SELECT_CURRENCY_DROPDOWN + " ul"), DEFAULT_ITERATIONS)); List<WebElement> elements = selectCurrencyDropdown.findElements(By.cssSelector(" li a")); for (WebElement element : elements) { currencies.add(element.getAttribute("data-currencycode")); } return currencies; }
From source file:com.hotwire.selenium.desktop.helpCenter.SFContactUsForm.java
License:Open Source License
public boolean isElementHighlighted(String elementName) { WebElement field; if ("subject".equals(elementName)) { field = findOne("div.sbHolder"); } else {/*from www . jav a 2s . c o m*/ field = getWebDriver().findElement(By.id(elementName)); } return field.getAttribute("class").contains("errorInput"); }
From source file:com.hotwire.selenium.desktop.row.search.AbstractFareFinder.java
License:Open Source License
@Override public List<String> getSearchSuggestions(String destinationLocation) { List<String> searchSuggestions = new ArrayList<String>(); location.setText(destinationLocation); // Do not debug this code! When browser loose focus it closes autocomplete popup. new WebDriverWait(getWebDriver(), 10, WebDriverWait.DEFAULT_SLEEP_TIMEOUT).until( ExpectedConditions.visibilityOfElementLocated(By.cssSelector("div.yui-ac-content ul li div"))); for (WebElement e : getWebDriver().findElements(By.cssSelector("div.yui-ac-content ul li div"))) { searchSuggestions.add(e.getAttribute("title")); }/*from w w w . j av a2 s . c o m*/ // Bad magic is done, feel free to debug... return searchSuggestions; }
From source file:com.hotwire.selenium.desktop.seo.DestinationListPage.java
License:Open Source License
public ArrayList<String> getDestinationUrls() { ArrayList<String> hrefs = new ArrayList<>(); List<WebElement> aTags = cityList.findElements(By.tagName("a")); for (WebElement aTag : aTags) { String href = aTag.getAttribute("href"); hrefs.add(href);// w w w. j a v a 2 s .c om } return hrefs; }
From source file:com.hotwire.selenium.desktop.seo.InformationPageUS.java
License:Open Source License
private ArrayList<String> getColumnUrls(boolean getLeftColumn, String vertical) { ArrayList<WebElement> urls = getColumnUrlsWebElements(getLeftColumn, vertical); ArrayList<String> urlText = new ArrayList<String>(); for (WebElement e : urls) { urlText.add(e.getAttribute("href")); }//from w w w .j a v a 2 s. c om return urlText; }
From source file:com.hotwire.selenium.desktop.us.billing.AbstractBillingPage.java
License:Open Source License
/** * This is fast solve. Will be fixed in the near feature! * checks that selected solution is prepaid *///w ww.ja v a 2 s .co m public boolean isPrepaidSolution() { try { WebElement reviewDetailsFragment = getWebDriver() .findElement(By.xpath("//div[contains(@class, 'reviewCarDetails')]")); return "true".equals(reviewDetailsFragment.getAttribute("data-prepaid")); } catch (NoSuchElementException e) { // no action } return false; }
From source file:com.hotwire.selenium.desktop.us.billing.car.impl.accordion.AcPaymentMethodFragment.java
License:Open Source License
public WebElement getPaymentState() { for (WebElement element : getWebDriver().findElements(By.cssSelector(container + " .countryFields .state select, " + container + " .countryFields .provinceCanada select, " + container + " .countryFields .provinceOther input"))) { LOGGER.info("PAYMENT STATE: " + element.getAttribute("id")); if (element.isDisplayed()) { return element; }/*from ww w .j ava 2 s. co m*/ } return null; }
From source file:com.hotwire.selenium.desktop.us.billing.car.impl.accordion.AcPaymentMethodFragment.java
License:Open Source License
@Override public String getNameOfChosenPaymentMethod() { List<WebElement> listOfPaymentMethods = getWebDriver().findElements( By.cssSelector("div.paymentMethod" + " div.paymentMethodSelector div input[type='radio']")); for (WebElement a : listOfPaymentMethods) { if (a.isSelected()) { return a.getAttribute("id"); }//from w ww . j a v a 2 s .c om } return "null"; }
From source file:com.hotwire.selenium.desktop.us.billing.car.impl.ccf.CcfPaymentMethodFragment.java
License:Open Source License
public String getNameOfChosenPaymentMethod() { List<WebElement> listOfPaymentMethods = getWebDriver().findElements( By.cssSelector("div.paymentMethod" + " div.paymentMethodSelector div input[type='radio']")); for (WebElement a : listOfPaymentMethods) { if (a.isSelected()) { return a.getAttribute("id"); }//from w w w . j a v a 2 s.c o m } return "null"; }