List of usage examples for org.openqa.selenium WebElement getTagName
String getTagName();
From source file:gov.nih.nci.firebird.commons.selenium2.util.TableUtils.java
License:Open Source License
private static void verifyElement(WebElement element, String expectedTag) { if (element != null) { String actualTag = element.getTagName(); assert (actualTag.equalsIgnoreCase(expectedTag)) : "Expected element to have tag " + expectedTag + " but was " + actualTag; }/*from w w w . j a v a2 s.co m*/ }
From source file:imagedownload.Downloader.java
private String getXpath(WebDriver driver, WebElement elm, String currentPath) { System.out.println("Current path: " + currentPath); StringBuilder path = new StringBuilder(); path.append("/" + elm.getTagName()); path.append(currentPath);//from ww w . j a v a2 s .c o m // if(elm.getAttribute("id")!=null && !elm.getAttribute("id").equals("")){ // subPath.append("[@id='"+elm.getAttribute("id")+"']"); // }else if(elm.getAttribute("class")!=null && !elm.getAttribute("class").equals("")){ // subPath.append("[@class='"+elm.getAttribute("class")+"']"); // } JavascriptExecutor executor = (JavascriptExecutor) driver; WebElement parentElement = (WebElement) executor.executeScript("return arguments[0].parentNode;", elm); return (elm.getTagName().equalsIgnoreCase("html") || parentElement == null) ? path.toString() : getXpath(driver, parentElement, path.toString()); }
From source file:info.magnolia.integrationtests.uitest.ContactsAppUITest.java
License:Open Source License
/** * Test modifies a contact & publishes it, thus creates a version of it. It checks, if 'show versions' * action is available then and displays that version. All fields have to be read only *//*from w w w. j a va 2 s . c om*/ @Test public void versionContactAndShowVersionedItemAndVerifyItemIsNotEditable() { // GIVEN final String contactName = "Marilyn Monroe"; createVersionedContactOf(contactName); // WHEN // Click on show versions WebElement showVersions = getActionBarItem("Show versions"); showVersions.click(); delay("Waiting for the popup to show up"); // Click on version drop-down to show versions getElement(By.xpath("//*[contains(@class, 'v-filterselect-input')]")).click(); // Get version drop-down WebElement table = getElement(By.xpath("//div[contains(@class, 'popupContent')]//div/table")); assertTrue("We expect to have at least one version", table.findElements(By.xpath("tbody/tr")).size() >= 1); // Click on show version getDialogButton("v-button-commit").click(); delay("Waiting for the editSubApp to open"); // Get inputs List<WebElement> inputs = getElements( By.xpath("//div[@class='form-content']//input[contains(@class, 'v-textfield')]"), CONTACTS_APP_INPUT_COUNT); assertNotNull(inputs); // THEN // Assert subApp is open and all fields in editor are readonly // Tab name will contain a version number waitUntil(visibilityOfElementLocated(byTabContainingCaption(contactName))); for (WebElement element : inputs) { assertEquals("We expect element [" + element.getTagName() + "] to be readonly", "true", element.getAttribute("readonly")); } // Assert button "commit" is not shown waitUntil(elementIsGone(byButtonClassnameAndCaption("v-button-commit", "save changes"))); }
From source file:info.magnolia.integrationtests.uitest.ContactsAppUITest.java
License:Open Source License
/** * Test modifies a contact & publishes it, thus creates a version of it. It checks, if 'show versions' * action is available then and displays that version. All fields have to be read only. Going back * to the browser, it now edits the same contact and checks that all fields are editable again. * It also checks in between whether the button (commit) has been deactivated (versioned contacts) * and activated after switching back to edit-mode. */// w ww . j a v a 2 s. co m @Test public void versionContactAndShowVersionedItemThenOpenEditModeAndVerifyItemIsEditable() { // GIVEN final String contactName = "Vincent Van Gogh"; createVersionedContactOf(contactName); // Click on show versions WebElement showVersions = getActionBarItem("Show versions"); showVersions.click(); delay("Waiting for the popup to show up"); // Click on version drop-down to show versions getElement(By.xpath("//*[contains(@class, 'v-filterselect-input')]")).click(); // Get version drop-down WebElement table = getElement(By.xpath("//div[contains(@class, 'popupContent')]//div/table")); assertTrue("We expect to have at least one version", table.findElements(By.xpath("tbody/tr")).size() >= 1); // Click on show version getDialogButton("v-button-commit").click(); delay("Waiting for the editSubApp to open"); // Get inputs List<WebElement> inputs = getElements( By.xpath("//div[@class='form-content']//input[contains(@class, 'v-textfield')]"), CONTACTS_APP_INPUT_COUNT); assertNotNull(inputs); // Assert subApp is open and all fields in editor are readonly // Tab name will contain a version number waitUntil(visibilityOfElementLocated(byTabContainingCaption(contactName))); for (WebElement element : inputs) { assertEquals("We expect element [" + element.getTagName() + "] to be readonly", "true", element.getAttribute("readonly")); } // WHEN // Click back to browser openTabWithCaption("Contacts"); waitUntil(tabIsOpen("Contacts")); // And open contacts in edit mode getActionBarItem("Edit contact").click(); delay("Waiting for the editSubApp to open"); // Get inputs afterwards List<WebElement> inputsEditable = getElements( By.xpath("//div[@class='form-content']//input[contains(@class, 'v-textfield')]"), CONTACTS_APP_INPUT_COUNT); assertNotNull(inputsEditable); // THEN // Assert fields are editable afterwards waitUntil(visibilityOfElementLocated(byTabContainingCaption(contactName))); for (WebElement element : inputsEditable) { assertEquals("We expect element [" + element.getTagName() + "] with value [" + element.getAttribute("value") + "] to be editable", null, element.getAttribute("readonly")); } // Assert button "commit" is shown waitUntil(visibilityOfElementLocated(byButtonClassnameAndCaption("v-button-commit", "save changes"))); }
From source file:io.ddavison.conductor.Locomotive.java
License:Open Source License
public String getText(By by) { String text;/*from w ww .j av a2s . c o m*/ WebElement e = waitForElement(by); if (e.getTagName().equalsIgnoreCase("input") || e.getTagName().equalsIgnoreCase("select") || e.getTagName().equalsIgnoreCase("textarea")) text = e.getAttribute("value"); else text = e.getText(); return text; }
From source file:io.github.seleniumquery.by.css.pseudoclasses.ButtonPseudoClass.java
License:Apache License
@Override public boolean isPseudoClass(WebDriver driver, WebElement element, PseudoClassSelector pseudoClassSelector) { return (INPUT.equals(element.getTagName()) && BUTTON.equalsIgnoreCase(element.getAttribute("type"))) || BUTTON.equals(element.getTagName()); }
From source file:io.github.seleniumquery.by.css.pseudoclasses.DisabledPseudoClass.java
License:Apache License
@Override public boolean isPseudoClass(WebDriver driver, WebElement element, PseudoClassSelector pseudoClassSelector) { // #Cross-Driver // When there is a not disabled <option> under a disabled <optgroup>, HtmlUnitDriver considers // the <option> to be enabled, when it is not if (DriverVersionUtils.getInstance().isHtmlUnitDriver(driver) && OPTION.equals(element.getTagName())) { WebElement optionParent = SelectorUtils.parent(element); if (OPTGROUP.equals(optionParent.getTagName()) && !optionParent.isEnabled()) { return true; }/* www .ja va 2 s .c o m*/ } return !element.isEnabled() && DISABLEABLE_TAGS.contains(element.getTagName()); }
From source file:io.github.seleniumquery.by.css.pseudoclasses.EnabledPseudoClass.java
License:Apache License
@Override public boolean isPseudoClass(WebDriver driver, WebElement element, PseudoClassSelector pseudoClassSelector) { // #Cross-Driver // When there is a not disabled <option> under a disabled <optgroup>, HtmlUnitDriver considers // the <option> to be enabled, when it is not if (DriverVersionUtils.getInstance().isHtmlUnitDriver(driver) && OPTION_TAG.equals(element.getTagName())) { WebElement optionParent = SelectorUtils.parent(element); if (OPTGROUP_TAG.equals(optionParent.getTagName()) && !optionParent.isEnabled()) { return false; }/* ww w . java 2 s. c o m*/ } return element.isEnabled() && ENABLEABLE_TAGS.contains(element.getTagName()); }
From source file:io.github.seleniumquery.by.css.pseudoclasses.FocusablePseudoClass.java
License:Apache License
@Override public boolean isPseudoClass(WebDriver driver, WebElement element, PseudoClassSelector pseudoClassSelector) { if (!isVisible(element)) { return false; }/* w w w . jav a 2 s . com*/ if (DisabledPseudoClass.DISABLEABLE_TAGS.contains(element.getTagName())) { return element.isEnabled(); } if (element.getTagName().equals("a") && element.getAttribute("href") != null) { return true; } //noinspection SimplifiableIfStatement if (element.getTagName().equals("area") && element.getAttribute( "href") != null /* && inside a named map */ /* && there is a visible image using the map */) { return true; } return element.getAttribute("tabindex") != null; }
From source file:io.github.seleniumquery.by.css.pseudoclasses.InputTypeAttributePseudoClass.java
License:Apache License
@Override public boolean isPseudoClass(WebDriver driver, WebElement element, PseudoClassSelector pseudoClassSelector) { return "input".equals(element.getTagName()) && typeAttributeValue.equalsIgnoreCase(element.getAttribute("type")); }