List of usage examples for org.openqa.selenium WebElement getTagName
String getTagName();
From source file:com.dhenton9000.filedownloader.FileDownloader.java
License:Apache License
/** * Perform an HTTP Status Check upon/Download the image specified in the src attribute of a WebElement * * @param imageElement Selenium WebElement * @throws Exception/*w w w .ja va2 s . c o m*/ */ public void setURISpecifiedInImageElement(WebElement imageElement) throws Exception { if (imageElement.getTagName().equals("img")) { fileURI = new URI(imageElement.getAttribute("src")); } else { throw new Exception("You have not specified an <img> element!"); } }
From source file:com.dukescript.api.selenium.FindsByTest.java
License:Open Source License
@Test public void Element_tagName() { WebElement element = driver.findElement(By.id("input")); Assert.assertEquals("INPUT", element.getTagName()); }
From source file:com.dukescript.api.selenium.FindsByTest.java
License:Open Source License
@Test public void findElementByName() { WebElement element = driver.findElement(By.name("text")); Assert.assertEquals("INPUT", element.getTagName()); }
From source file:com.dukescript.api.selenium.FindsByTest.java
License:Open Source License
@Test public void Element_findElementByName() { WebElement parent = driver.findElement(By.id("form")); WebElement element = parent.findElement(By.name("text")); Assert.assertEquals("INPUT", element.getTagName()); }
From source file:com.dukescript.api.selenium.FindsByTest.java
License:Open Source License
@Test public void findElementByTagName() { WebElement element = driver.findElement(By.tagName("input")); Assert.assertEquals("INPUT", element.getTagName()); }
From source file:com.dukescript.api.selenium.FindsByTest.java
License:Open Source License
@Test public void Element_findElementByTagName() { WebElement parent = driver.findElement(By.id("form")); WebElement element = parent.findElement(By.tagName("input")); Assert.assertEquals("INPUT", element.getTagName()); }
From source file:com.ecfeed.core.runner.java.SeleniumTestMethodInvoker.java
License:Open Source License
private boolean processSelect(String elementType, MethodParameterNode methodParameterNode, String argument) { if (!NodePropertyDefElemType.isSelect(elementType)) { return false; }/* www . j av a 2s. c om*/ WebElement webElement = findWebElement(methodParameterNode); if (!isElementOkForInput(webElement)) { reportExceptionUnavailableElement(methodParameterNode); } String tagName = webElement.getTagName(); if (!StringHelper.isEqual(tagName, TAG_SELECT)) { return false; } List<WebElement> allOptions = webElement.findElements(By.tagName(TAG_OPTION)); for (WebElement option : allOptions) { String text = option.getText(); if (StringHelper.isEqual(text, argument)) { option.click(); return true; } } reportException("Option with text: '" + argument + "' not found.", methodParameterNode); return true; }
From source file:com.ecofactor.qa.automation.insite.page.InstallationHardwareImpl.java
License:Open Source License
@Override public void addThermostat(String thermostatName) { smallWait();/* w w w. j a va 2 s . c om*/ WebElement getAddressDiv = retrieveElementByAttributeValue(DriverConfig.getDriver(), TAG_DIV, ATTR_ID, "getAddressDiv"); logger.info("getAddressDiv ID: " + getAddressDiv.getAttribute("id")); WebElement tblHomeProfile = retrieveElementByAttributeValue(DriverConfig.getDriver(), TAG_TABLE, ATTR_ID, "homeProfile"); logger.info("tblHomeProfile: " + tblHomeProfile.getAttribute("class")); List<WebElement> newlyAddedTstats = retrieveElementsByContainsOfAttributeValue(DriverConfig.getDriver(), TAG_TD, ATTR_CLASS, "ef_dataTable toCountThermostats"); WebElement newlyAddedTstat = newlyAddedTstats.get(newlyAddedTstats.size() - 1); logger.info("Newly Added thermostat: " + newlyAddedTstat.getTagName(), true); DriverConfig.setLogString("Enter name for existing thermostat field as 'TestTstat'.", true); WebElement newTstatName = retrieveElementByAttributeValueByPassingElement(DriverConfig.getDriver(), newlyAddedTstat, TAG_INPUT, ATTR_TYPE, "text"); newTstatName.clear(); newTstatName.sendKeys("TestTstat"); tinyWait(); //click add link DriverConfig.setLogString("Click add thermostat link.", true); WebElement addThermostatElement = retrieveElementByAttributeValueByPassingElement(DriverConfig.getDriver(), getAddressDiv, TAG_ANCHOR, ATTR_ID, "addThermostat"); addThermostatElement.click(); tinyWait(); tblHomeProfile = retrieveElementByAttributeValue(DriverConfig.getDriver(), TAG_TABLE, ATTR_ID, "homeProfile"); logger.info("tblHomeProfile: " + tblHomeProfile.getAttribute("class"), true); newlyAddedTstats = retrieveElementsByContainsOfAttributeValue(DriverConfig.getDriver(), TAG_TD, ATTR_CLASS, "ef_dataTable toCountThermostats"); newlyAddedTstat = newlyAddedTstats.get(newlyAddedTstats.size() - 1); logger.info("newlyAddedTstat: " + newlyAddedTstat.getTagName(), true); DriverConfig.setLogString("Enter name for newly added thermostat" + thermostatName + ".", true); WebElement newTstatNameFld = retrieveElementByAttributeValueByPassingElement(DriverConfig.getDriver(), newlyAddedTstat, TAG_INPUT, ATTR_TYPE, "text"); newTstatNameFld.sendKeys(thermostatName); DriverConfig.setLogString("Click link gateway", true); WebElement LinkGateWayBtn = retrieveElementByAttributeValue(DriverConfig.getDriver(), TAG_INPUT, ATTR_ID, "nextStepButton"); LinkGateWayBtn.click(); tinyWait(); }
From source file:com.ecofactor.qa.automation.insite.page.SupportLookUpImpl.java
License:Open Source License
/** * Iterate results and verify empty fields. * @see com.ecofactor.qa.automation.insite.page.SupportLookUp#iterateResultsAndVerifyEmptyFields() *//*www. j a v a 2 s . co m*/ @Override public void iterateResultsAndVerifyEmptyFields() { DriverConfig.setLogString("Iterate Search Results and Verify empty results", true); List<WebElement> resultTr = retrieveElementsByAttributeValueList(DriverConfig.getDriver(), "tr", "id", "user"); boolean gateWayModelFound = false; String text = ""; for (WebElement trElement : resultTr) { if (gateWayModelFound) break; List<WebElement> resultTd = trElement.findElements(By.tagName("td")); int count = 0; for (WebElement tdElement : resultTd) { if (count == 9) text = tdElement.getText(); logger.info("Account status: " + text); if (text.contains("ACTIVE")) { WebElement idElement = resultTd.get(0); WebElement searchElement = retrieveElementByLinkText(DriverConfig.getDriver(), idElement.getText(), MEDIUM_TIMEOUT); logger.info("click active account.", true); searchElement.click(); WaitUtil.waitUntil(200); DriverConfig.setLogString("click Installed Hardware.", true); retrieveElementByLinkText(DriverConfig.getDriver(), "Installed Hardware", MEDIUM_TIMEOUT) .click(); WaitUtil.waitUntil(200); WebElement gateWayDiv = retrieveElementByAttributeValue(DriverConfig.getDriver(), TAG_DIV, ATTR_ID, "supportPage-gatewayDetails", MEDIUM_TIMEOUT); DriverConfig.setLogString("click Expand Gateway." + gateWayDiv.getTagName(), true); retrieveElementByAttributeValueContainsForSubElement(DriverConfig.getDriver(), gateWayDiv, TAG_IMG, ATTR_CLASS, "show", MEDIUM_TIMEOUT).click(); WaitUtil.waitUntil(200); DriverConfig.setLogString("Verify Gateway model.", true); List<WebElement> elementTD = retrieveElementsByTagText(DriverConfig.getDriver(), TAG_TD, "iControl Android Touchscreen"); for (WebElement element : elementTD) { DriverConfig.setLogString("element.getText() " + element.getText(), true); gateWayModelFound = true; break; } break; } count++; } } DriverConfig.setLogString("Check if gateway model 'iControl Android Touchscreen' found.", true); Assert.assertTrue(gateWayModelFound, "Gateway model 'iControl Android Touchscreen' not found."); }
From source file:com.elastica.webelements.SelectList.java
License:Apache License
/** * Select standard select by attribute text, and select fake select with ul and li by attribute title. * * @param text/*from w ww . j a v a2 s . c o m*/ */ public void selectByText(final String text) { TestLogging.logWebStep(null, "make selection using text\"" + text + "\" on " + toHTML(), false); findElement(); if (options == null) { driver.findElement(By.xpath("//li[text()='" + text + "']")).click(); return; } for (WebElement option : options) { String selectedText = null; if (option.getTagName().equalsIgnoreCase("li")) { selectedText = option.getAttribute("title"); } else { selectedText = option.getAttribute("text"); } if (selectedText.equals(text)) { setSelected(option); break; } } }