List of usage examples for org.openqa.selenium By tagName
public static By tagName(String tagName)
From source file:com.comcast.dawg.house.AdvanceFilterNavigator.java
License:Apache License
public void checkConditions(boolean check, String... conditionTexts) { WebElement conditionList = driver.findElementByClassName(IndexPage.CONDITION_LIST); List<WebElement> conditions = conditionList.findElements(By.tagName("div")); for (String conditionText : conditionTexts) { WebElement condition = getCondition(conditions, conditionText, true); WebElement conditionCheckBox = condition.findElement(By.className(IndexPage.CONDITION_CHECK_BOX)); if (conditionCheckBox.isSelected() != check) { conditionCheckBox.click();/*from w w w.j a v a2 s. c o m*/ } } }
From source file:com.comcast.dawg.house.ContextMenu.java
License:Apache License
/** * Finds the given menu item and then clicks it * @param cmi The item to click//from w ww . j ava2 s . co m */ public void clickMenuItem(ContextMenuItem cmi) { List<WebElement> items = menuUI.findElements(By.tagName("a")); for (WebElement item : items) { if (item.getText().equals(cmi.getDisp())) { item.click(); return; } } }
From source file:com.comcast.dawg.house.LoginPageIT.java
License:Apache License
/** * @author Kevin Pearson/*from www . j a v a 2 s.c o m*/ * @throws IOException */ @Test(description = "Tests if a user can input a user name and click enter to log in", groups = "uitest") public void testLogin() throws IOException { String user = "integrationuser"; RemoteWebDriver driver = drivers.get(); driver.get(TestServers.getHouse()); loginWithUserName(driver, user); String expectedNewPageUrl = TestServers.getHouse() + user + "/"; Assert.assertEquals(driver.getCurrentUrl(), expectedNewPageUrl); WebElement userInfo = driver.findElementByClassName(IndexPage.USER_SECTION_CLASS); List<WebElement> spans = userInfo.findElements(By.tagName(Tag.SPAN.toString())); Assert.assertFalse(spans.isEmpty()); WebElement userDisplaySpan = spans.get(0); // the first span should show the user name Assert.assertEquals(userDisplaySpan.getText(), user); }
From source file:com.comcast.dawg.house.pages.ModelPage.java
License:Apache License
/** * Return the list of capabilities already available on loaded model overlay. * * @return the list of capabilities.// w w w .j av a 2s . co m */ public List<String> getAllCapabilityNamesOnAlreadyLoadedModelOverlay() { List<String> capabilityList = new ArrayList<String>(); WebElement capabilityListDiv = driver.findElement(By.id(CAPABILITY_LIST_DIV_ID)); for (WebElement divCapability : capabilityListDiv.findElements(By.tagName(DIV_TAG_NAME))) { capabilityList.add(divCapability.getText()); } return capabilityList; }
From source file:com.consol.citrus.selenium.actions.FindElementAction.java
License:Apache License
/** * Create by selector from type information. * @return/* ww w . j av a 2s. c om*/ */ protected By createBy(TestContext context) { if (by != null) { return by; } switch (property) { case "id": return By.id(context.replaceDynamicContentInString(propertyValue)); case "class-name": return By.className(context.replaceDynamicContentInString(propertyValue)); case "link-text": return By.linkText(context.replaceDynamicContentInString(propertyValue)); case "css-selector": return By.cssSelector(context.replaceDynamicContentInString(propertyValue)); case "name": return By.name(context.replaceDynamicContentInString(propertyValue)); case "tag-name": return By.tagName(context.replaceDynamicContentInString(propertyValue)); case "xpath": return By.xpath(context.replaceDynamicContentInString(propertyValue)); } throw new CitrusRuntimeException("Unknown selector type: " + property); }
From source file:com.consol.citrus.selenium.actions.FindElementActionTest.java
License:Apache License
@DataProvider public Object[][] findByProvider() { return new Object[][] { new Object[] { "id", "myId", By.id("myId") }, new Object[] { "name", "myName", By.name("myName") }, new Object[] { "tag-name", "button", By.tagName("button") }, new Object[] { "class-name", "myClass", By.className("myClass") }, new Object[] { "link-text", "myLinkText", By.linkText("myLinkText") }, new Object[] { "css-selector", "myCss", By.cssSelector("myCss") }, new Object[] { "xpath", "myXpath", By.xpath("myXpath") } }; }
From source file:com.consol.citrus.selenium.client.WebClient.java
License:Apache License
public static By getByFromEnum(ByEnum byEnum, String select) { By by = null;/* w ww . ja v a 2 s . com*/ switch (byEnum) { case ID: by = By.id(select); break; case CLASS_NAME: by = By.className(select); break; case LINK_TEXT: by = By.linkText(select); break; case CSS_SELECTOR: by = By.cssSelector(select); break; case NAME: by = By.name(select); break; case TAG_NAME: by = By.tagName(select); break; case XPATH: by = By.xpath(select); break; } return by; }
From source file:com.deque.axe.AXE.java
License:Mozilla Public License
/** * Recursively find frames and inject a script into them. * @param driver An initialized WebDriver * @param script Script to inject// www .ja va 2 s . c om * @param parents A list of all toplevel frames */ private static void injectIntoFrames(final WebDriver driver, final String script, final ArrayList<WebElement> parents) { final JavascriptExecutor js = (JavascriptExecutor) driver; final List<WebElement> frames = driver.findElements(By.tagName("iframe")); for (WebElement frame : frames) { driver.switchTo().defaultContent(); if (parents != null) { for (WebElement parent : parents) { driver.switchTo().frame(parent); } } driver.switchTo().frame(frame); js.executeScript(script); ArrayList<WebElement> localParents = (ArrayList<WebElement>) parents.clone(); localParents.add(frame); injectIntoFrames(driver, script, localParents); } }
From source file:com.deque.axe.ExampleTest.java
License:Mozilla Public License
/** * Test a WebElement/*from www . j a v a 2s . co m*/ */ @Test public void testAccessibilityWithWebElement() { JSONObject responseJSON = new AXE.Builder(driver, scriptUrl).analyze(driver.findElement(By.tagName("p"))); JSONArray violations = responseJSON.getJSONArray("violations"); if (violations.length() == 0) { assertTrue("No violations found", true); } else { AXE.writeResults(testName.getMethodName(), responseJSON); assertTrue(AXE.report(violations), false); } }
From source file:com.dhenton9000.selenium.generic.GenericAutomationRepository.java
/** * generate the By selector// ww w . j a v a2s . c o m * * @param selectorChoice the desired selector, eg by css Selector * @param selectorValue the string to search for * @return the By element */ public static By generateSelectorBy(SELECTOR_CHOICE selectorChoice, String selectorValue) { By selectorBy = null; switch (selectorChoice) { case id: selectorBy = By.id(selectorValue); break; case name: selectorBy = By.name(selectorValue); break; case className: selectorBy = By.className(selectorValue); break; case linkText: selectorBy = By.linkText(selectorValue); break; case xpath: selectorBy = By.xpath(selectorValue); break; case tagName: selectorBy = By.tagName(selectorValue); break; case cssSelector: selectorBy = By.cssSelector(selectorValue); break; case partialLinkText: selectorBy = By.partialLinkText(selectorValue); break; case wicketPathMatch: selectorBy = WicketBy.wicketPathMatch(selectorValue); break; case wicketPathContains: selectorBy = WicketBy.wicketPathContains(selectorValue); break; default: throw new AssertionError("unable to match selector " + selectorChoice.name()); } return selectorBy; }