List of usage examples for org.openqa.selenium WebElement getAttribute
String getAttribute(String name);
From source file:com.cognifide.qa.bb.utils.WebElementUtils.java
License:Apache License
/** * Checks if specified WebElement has specified attribute within specified timeout. * * @param element WebElement to be checked. * @param attribute name of the attribute which presence is to be checked. * @param value value which presence in attribute is to be checked. * @param timeout timeout in seconds within which the WebElement has to have specified * attribute./*from ww w . ja v a 2 s . c o m*/ * @return value indicating if specified WebElement has specified attribute with specified value. */ public boolean hasAttributeWithValue(final WebElement element, final String attribute, final String value, int timeout) { return isConditionMet(webDriver -> element.getAttribute(attribute).contains(value), timeout); }
From source file:com.cognifide.qa.bb.webelement.BobcatWebElement.java
License:Apache License
private boolean isUploadField(WebElement webElement) { boolean tagIsInput = "input".equals(webElement.getTagName()); boolean typeIsFile = "file".equals(webElement.getAttribute("type")); return tagIsInput && typeIsFile; }
From source file:com.coinbot.core.InputAddressDetector.java
License:Open Source License
public void insertAddress(String address) { List<WebElement> inputs = driver.findElements(By.tagName("input")); for (WebElement input : inputs) { if (input.getAttribute("name").length() > 20) { input.sendKeys(address);//from www . j ava2 s . com } } }
From source file:com.comcast.dawg.house.AdvanceFilterNavigator.java
License:Apache License
/** * Checks if the given condition checks are in the condition list * @param conditions The conditions to look through * @param conditionTexts The texts to check if they exist * @param checked True if all the given conditions are checked *//*from w w w. ja v a 2 s . c o m*/ public void verifyConditions(List<WebElement> conditions, String[] conditionTexts, boolean checked) { for (String c : conditionTexts) { WebElement found = getCondition(conditions, c); Assert.assertNotNull(found); WebElement conditionCheckBox = found.findElement(By.className(IndexPage.CONDITION_CHECK_BOX)); Assert.assertEquals(conditionCheckBox.getAttribute("checked") != null, checked); } }
From source file:com.comcast.dawg.house.pages.IndexPage.java
License:Apache License
/** * Is delete option displayed in tag element on tag cloud. * * @param tagName Name of the tag./*ww w. j av a 2s. c o m*/ * * @return true if delete option is available on tag element. */ public boolean isDeleteOptionDisplayedInTag(String tagName) { WebElement tagDeleteDivElement = getTagDeleteDivElement(tagName); String styleAtrributeValue = tagDeleteDivElement.getAttribute(TAG_DELETE_OPTION_STYLE_ATTRIBUTE); LOGGER.info("Style option of delete div : " + styleAtrributeValue); int opacityBeginningIndex = styleAtrributeValue.lastIndexOf(OPACITY_BEGINNING_CHAR) + 1; int opacityEndingIndex = styleAtrributeValue.lastIndexOf(OPACITY_ENDING_CHAR); String opacityStr = styleAtrributeValue.substring(opacityBeginningIndex, opacityEndingIndex); LOGGER.info("String Opacity value : " + opacityStr); double opacity = Double.parseDouble(opacityStr); return opacity > 0; }
From source file:com.comcast.dawg.house.pages.IndexPage.java
License:Apache License
/** * Return the list of all device id div element under filtered table div element. * * @return the list of device Ids.// ww w . j ava2s . co m */ public List<String> getStbFilteredTableDivElementsDeviceIdAttribute() { List<String> deviceIds = new ArrayList<String>(); for (WebElement div : getStbFilteredTableSuccessorDivElements()) { deviceIds.add(div.getAttribute(FILTERED_TABLE_DEVICE_ID_ATTRIBUTE)); } return deviceIds; }
From source file:com.comcast.dawg.house.pages.IndexPage.java
License:Apache License
/** * Provides the set-top meta data span text content. * * @param stbId tag name to be clicked. * @param spanCssClassName Class name of span element. * * @return Meta data span content./*w ww.j a v a 2s . c om*/ */ public String getStbMetaDataSpanTextContent(String stbId, String spanCssClassName) { WebElement settopFilterRow = getStbFilterDivRowElement(stbId); LOGGER.info("Data Device ID : " + settopFilterRow.getAttribute("data-deviceId")); WebElement metaDataDivTag = settopFilterRow.findElement(By.className("metadata")); WebElement tagNameSpan = metaDataDivTag.findElement(By.cssSelector("span." + spanCssClassName)); return tagNameSpan.getAttribute("textContent"); }
From source file:com.common.ExpectedConditions.java
License:Apache License
/** * An expectation for checking if the given text is present in the specified * elements value attribute./* ww w . ja va 2s .c o m*/ * * @param element the WebElement * @param text to be present in the element's value attribute * @return true once the element's value attribute contains the given text */ public static ExpectedCondition<Boolean> textToBePresentInElementValue(final WebElement element, final String text) { return new ExpectedCondition<Boolean>() { @Override public Boolean apply(WebDriver driver) { try { String elementText = element.getAttribute("value"); if (elementText != null) { return elementText.contains(text); } else { return false; } } catch (StaleElementReferenceException e) { return null; } } @Override public String toString() { return String.format("text ('%s') to be the value of element %s", text, element); } }; }
From source file:com.common.ExpectedConditions.java
License:Apache License
public static ExpectedCondition<Boolean> textToBeMatchInElementValue(final WebElement element, final String regex) { return new ExpectedCondition<Boolean>() { @Override// ww w .j a va 2s .c o m public Boolean apply(WebDriver driver) { try { String elementText = element.getAttribute("value"); if (elementText != null) { return elementText.matches(regex); } else { return false; } } catch (StaleElementReferenceException e) { return null; } } @Override public String toString() { return String.format("text ('%s') to be the value of element %s", regex, element); } }; }
From source file:com.company.components.impl.SearchBoxImpl.java
License:Apache License
private List<String> getSuggestions() { List<String> suggestions = new ArrayList<String>(); for (WebElement item : getSuggestionItems()) { suggestions.add(item.getAttribute("title")); }//from w w w .j a v a2 s .c o m return suggestions; }