List of usage examples for org.openqa.selenium WebElement getTagName
String getTagName();
From source file:br.gov.frameworkdemoiselle.behave.runner.webdriver.ui.WebBase.java
License:Open Source License
public void isVisibleDisabled() { List<WebElement> elementsFound = getElements(); if (elementsFound.size() > 0) { WebElement e = elementsFound.get(0); // Tem que estar Visvel e Desabilitado, se estiver invisvel OU // habilitado lana a exception if (e.getTagName().toLowerCase().equals("input") || e.getTagName().toLowerCase().equals("select") || e.getTagName().toLowerCase().equals("a")) { // Verifica tambm se tem o atributo READONLY no elemento String readonlyAttribute = e.getAttribute("readonly"); String disabledAttribute = e.getAttribute("disabled"); // SE no estiver visivel OU (no possuir o attr DISABLED E no // possuir o attr READONLY) ENTO de erro! if (!e.isDisplayed() || (disabledAttribute == null && readonlyAttribute == null)) { throw new BehaveException(message.getString("exception-element-not-displayed-or-enabled", getElementMap().name())); }// ww w .j ava 2 s .co m } else { // Faz a verificao se esta desabilitado por meio das classes // de css para os casos de combo estilo Primefaces e Richfaces String classes = e.getAttribute("class"); if (!e.isDisplayed() || !classes.contains("disabled")) { throw new BehaveException(message.getString("exception-element-not-displayed-or-enabled", getElementMap().name())); } } } else { throw new BehaveException(message.getString("exception-element-not-found", getElementMap().name())); } }
From source file:br.gov.frameworkdemoiselle.behave.runner.webdriver.ui.WebImage.java
License:Open Source License
/** * {@inheritDoc}// w w w .j a va 2 s .co m */ @Override public void checkSource(String src) { waitElement(0); List<WebElement> elements = getElements(); WebElement element = elements.get(0); if (element.getTagName().equals("img")) { if (!element.getAttribute("src").contains(src)) { throw new BehaveException(message.getString("exception-attribute-not-contains-value", "src", src, getElementMap().name())); } } else { throw new BehaveException(message.getString("element-is-not-type", getElementMap().name(), "image")); } }
From source file:br.ufmg.dcc.saotome.beholder.selenium.WebElementAdapter.java
License:Apache License
@Override public String getTagName() { return new StaleExceptionResolver<String>() { @Override/*from w w w . jav a 2 s . c o m*/ public String execute(WebElement element) { return element.getTagName(); } }.waitForElement(); }
From source file:ch.vorburger.webdriver.reporting.LoggingWebDriverEventListener.java
License:Apache License
private String getTagNameSafely(WebElement element) { try {//from ww w . j a va2 s .c o m return element.getTagName(); } catch (WebDriverException e) { // If we couldn't get the attribute, something is wrong, it probably // doesn't have one, so let's just return null: return null; } }
From source file:chromedriveryahoologin.ChromeDriverDeleteTrashEmails.java
public static void main(String[] args) { try {// w w w .java 2s .com Integer pozSpam = 0; Integer pozTrash = 0; Integer pozHelp = 0; Integer pozCompose = 0; Integer pozNewFolder = 0; System.setProperty("webdriver.chrome.driver", "D:\\Proiecte\\selenium-java-2.47.1\\selenium-2.47.1\\chromedriver_win32\\chromedriver.exe"); System.setProperty("webdriver.chrome.logfile", "D:\\prjAutJava\\YahooLogin\\ChromeDriverDeleteSpam.log"); ChromeOptions options = new ChromeOptions(); options.addArguments("test-type"); options.addArguments("--start-maximized"); options.addArguments("--disable-web-security"); options.addArguments("--no-proxy-server"); options.addArguments("--disable-extensions"); options.addArguments("--disable-notifications"); options.addArguments("--disable-popup-blocking"); options.addArguments("--disable-plug-in"); Map<String, Object> prefs = new HashMap<String, Object>(); prefs.put("credentials_enable_service", false); prefs.put("profile.password_manager_enabled", false); options.setExperimentalOption("prefs", prefs); DesiredCapabilities capabilities = DesiredCapabilities.chrome(); capabilities.setCapability(ChromeOptions.CAPABILITY, options); capabilities.setCapability(CapabilityType.SUPPORTS_APPLICATION_CACHE, true); capabilities.setCapability(CapabilityType.SUPPORTS_FINDING_BY_CSS, true); capabilities.setCapability(CapabilityType.SUPPORTS_LOCATION_CONTEXT, true); capabilities.setCapability(CapabilityType.SUPPORTS_ALERTS, true); capabilities.setCapability(CapabilityType.PLATFORM, "WIN10"); driver = new ChromeDriver(capabilities); driver.manage().timeouts().implicitlyWait(30, TimeUnit.SECONDS); driver.get("https://mail.yahoo.com"); driver.manage().window().maximize(); WebElement usernameElem = driver.findElement(By.id("login-username")); usernameElem.sendKeys("andadeacu@yahoo.com"); WebElement Next = driver.findElement(By.name("signin")); Next.click(); driver.manage().timeouts().implicitlyWait(30, TimeUnit.SECONDS); WebElement passwordElem = driver.findElement(By.xpath("//input[@id='login-passwd']")); boolean selected = passwordElem.isSelected(); CharSequence password = ""; passwordElem.sendKeys(password); WebElement login = driver.findElement(By.id("login-signin")); login.click(); driver.manage().timeouts().implicitlyWait(60, TimeUnit.SECONDS); driver.switchTo().activeElement(); WebElement tooltipElem = driver.findElement(By.xpath("//div[@class='Pos(r) M(0) TooltipContent']")); List<WebElement> childs = tooltipElem.findElements(By.xpath("//ul/li")); for (int j = 0; j < childs.size(); j++) { WebElement spamElem = childs.get(j); /* * System.out.println("ancorele " + j + " " + " tag " + * childs.get(j).getTagName() + " " + childs.get(j).getText() + * " " + childs.get(j).getAttribute("innerHTML")); */ if (spamElem.getText().startsWith(("Spam"))) { pozSpam = j; } if (spamElem.getText().startsWith(("Help"))) { pozHelp = j; } if (spamElem.getText().startsWith(("Compose"))) { pozCompose = j; } if (spamElem.getText().startsWith(("New"))) { pozNewFolder = j; } if (spamElem.getText().startsWith(("Trash"))) { System.out.println(j + " Trash is " + spamElem.getTagName() + " " + spamElem.getText()); pozTrash = j; break; } } System.out.println(pozTrash); WebElement trashElem = childs.get(pozTrash); /* * System.out.println("trashElem " + trashElem.getTagName() + * " text " + trashElem.getText() + " class_atribute " + * trashElem.getAttribute("class") + " data_action " + * trashElem.getAttribute("data_action")); */ WebElement trashFolderEmpty = trashElem.findElement( By.xpath("//a[@class='x-gap btn btn-trash']/span/span[@class='btn icon icon-delete']")); /* * System.out.println("spamEmptyFolder " + * spamFolderEmpty.getTagName() + " text " + * spamFolderEmpty.getText() + " location " + * spamFolderEmpty.isEnabled()); */ trashFolderEmpty.click(); int timeOut = 5; WebDriverWait wait = new WebDriverWait(driver, timeOut); driver.switchTo().alert(); /* for Chrome is not working WebElement modalPopUp = driver.findElement(By .className("modal-hd yui3-widget-hd")); */ WebElement btnDeleteSpamEmails = driver.findElement(By.className("btn left right default")); /* * <button id="okayModalOverlay" class="btn left right default" * title="OK" role="button" data-action="ok">OK</button> */ btnDeleteSpamEmails.click(); driver.manage().timeouts().implicitlyWait(60, TimeUnit.SECONDS); driver.switchTo().activeElement(); // verify msg after you delete spam emails System.out.println(driver.getCurrentUrl()); driver.quit(); } catch (Exception ex) { ex.printStackTrace(); driver.quit(); } }
From source file:com.atomicleopard.webelemental.ElementTest.java
License:Open Source License
public static WebElement webElement(String element, String text, final Map<String, String> attributes) { WebElement webElement = mock(WebElement.class); when(webElement.getTagName()).thenReturn(element); when(webElement.getText()).thenReturn(text); when(webElement.getAttribute(anyString())).thenAnswer(new Answer<String>() { public String answer(InvocationOnMock invocation) throws Throwable { String key = (String) invocation.getArguments()[0]; return attributes.get(key); }//from www . j a va 2s .c o m }); return webElement; }
From source file:com.autocognite.selenium.lib.SeleniumWebUiDriver.java
License:Apache License
public UiElementType getElementType(WebElement wdElement) { String tagName = wdElement.getTagName().toLowerCase(); if (tagName.equals("select")) { return UiElementType.DROPDOWN; } else if (tagName.equals("input") && wdElement.getAttribute("type").toLowerCase().equals("radio")) { return UiElementType.RADIO; } else {//from w w w. java 2s . co m return UiElementType.GENERIC; } }
From source file:com.chtr.tmoauto.webui.CommonFunctions.java
License:Open Source License
@Override public void waitForElementVisible(WebElement locator, int timeoutInSeconds) throws ElementNotVisibleException { WebElement e = null;//from w ww. j a v a 2 s . c om log.debug("Wait for Element Visible should time out in " + timeoutInSeconds); e = (new WebDriverWait(webDriver, timeoutInSeconds)).until(ExpectedConditions.visibilityOf(locator)); log.debug("end wait for Element Visible"); if (e != null) { return; } else { throw new ElementNotVisibleException(locator.getTagName() + " did not become visible."); } }
From source file:com.cognifide.bdd.demo.po.feedback.TitleComponent.java
License:Apache License
/** * Search for the web element of title as it could be replaced by JavaScript in the meantime. * * @return tag name for the title, most likely something like: H1, H2,.. *//*w ww. j ava2s . c o m*/ public String findTitleFormattingTag() { bobcatWait.withTimeout(Timeouts.MEDIUM).until(ExpectedConditions.visibilityOf(currentScope)); WebElement titleTagFound = currentScope.findElement(TITLE_TAG_BY); return titleTagFound.getTagName(); }
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; }