List of usage examples for org.openqa.selenium By tagName
public static By tagName(String tagName)
From source file:com.nosoftskills.travianbot.page.FarmList.java
License:Apache License
public void raidSingleList(String listName) { List<WebElement> listTitles = webDriver.findElements(By.className("listTitleText")); int i = 0;//www.j a v a 2 s . c om for (WebElement listTitle : listTitles) { if (listTitle.getText().trim().equals(listName)) { break; } i++; } List<WebElement> raidTables = webDriver.findElements(By.className("list")); if (raidTables.size() == 0) { throw new IllegalStateException( "Page was not loaded. Most probably the server is down or you don't have internet"); } List<WebElement> startRaidButtons = webDriver.findElements(By.tagName("button")).stream().filter( buttonElement -> buttonElement.getAttribute("value").equals(" ")) .collect(Collectors.toList()); doRaid(raidTables.get(i), startRaidButtons.get(i)); }
From source file:com.nosoftskills.travianbot.page.Home.java
License:Apache License
private IncomingAttack createIncomingAttack(WebElement webElement) { IncomingAttack incomingAttack = new IncomingAttack(webElement.findElement(By.className("name")).getText()); incomingAttack.setVillageLink(webElement.findElement(By.tagName("a")).getAttribute("href")); return incomingAttack; }
From source file:com.nosoftskills.travianbot.page.Home.java
License:Apache License
private IncomingAttack attachAttackDetails(IncomingAttack incomingAttack) { webDriver.get(incomingAttack.getVillageLink()); WebElement movementsTable = webDriver.findElement(By.id("movements")); WebElement attackRow = movementsTable.findElements(By.tagName("tr")).stream() .filter(webElement -> !webElement.findElements(By.cssSelector(".att1")).isEmpty() || !webElement.findElements(By.cssSelector(".att3")).isEmpty()) .findFirst().orElseThrow(IllegalArgumentException::new); incomingAttack.setInTime(attackRow.findElement(By.className("timer")).getText()); WebElement attackDescription = attackRow.findElement(By.cssSelector(".a1")); if (attackDescription == null) { attackDescription = attackRow.findElement(By.cssSelector(".a1")); }/*from w ww . j a v a2s .c o m*/ incomingAttack.setNumberOfAttacks(attackDescription.getText().split(" ")[0]); return incomingAttack; }
From source file:com.novartis.opensource.yada.test.YADAAdminTest.java
License:Apache License
/** * Tests splash screen/*from w w w. java2 s. co m*/ */ @Test(priority = 0) public void testLandingPage() { WebDriver d = getDriver(); for (WebElement e : d.findElement(By.tagName("nav")).findElements(By.cssSelector("li a"))) { try { e.click(); } catch (WebDriverException e1) { l.debug("Navbar unclickable as expected."); } } WebElement e = d.findElement(By.id("app-mgr")); Assert.assertFalse(e.isDisplayed()); e = d.findElement(By.id("query-table")); Assert.assertFalse(e.isDisplayed()); e = d.findElement(By.id("qname-copy")); Assert.assertFalse(e.isDisplayed()); e = d.findElement(By.id("migration-target-selector")); Assert.assertFalse(e.isDisplayed()); e = d.findElement(By.id("query-editor-container")); Assert.assertFalse(e.isDisplayed()); e = d.findElement(By.id("compare")); Assert.assertFalse(e.isDisplayed()); new WebDriverWait(d, 300) .until(ExpectedConditions.presenceOfElementLocated(By.cssSelector("#login .modal-dialog"))); Assert.assertFalse(d.findElement(By.id("login-btn")).isEnabled()); }
From source file:com.opera.core.systems.FindElementsTest.java
License:Apache License
@Test public void testMultipleElements() throws Exception { OperaWebElement form = (OperaWebElement) driver.findElementByTagName("form"); List<WebElement> els = form.findElements(By.tagName("input")); Assert.assertEquals(5, els.size());/*from w w w. j a v a 2 s. c o m*/ for (WebElement el : els) { Assert.assertEquals(el.getTagName(), "INPUT"); } }
From source file:com.opera.core.systems.ScreenshotTest.java
License:Apache License
@Test public void testZeroHeight() throws Exception { // Shouldn't throw exceptions getFixture("zero-height-standards.html"); ((OperaWebElement) driver.findElement(By.tagName("html"))).getImageHash(); getFixture("zero-height-quirks.html"); ((OperaWebElement) driver.findElement(By.tagName("html"))).getImageHash(); }
From source file:com.osbitools.ws.pd.xui.PageDesignerGuiWebTest.java
License:LGPL
@Override public void checkInitBodyState(String lang, WebElement ctx, String pname, String qname) { WebElement ccw = ctx.findElement(By.className("comp-cont-wrapper")); WebElement ccont = ccw.findElement(By.tagName("table")); assertEquals("Component Container table class name doesn't match", "comp-container", ccont.getAttribute("class")); WebElement cpanel = ccont.findElement(By.tagName("td")); assertEquals("Component Container table class name doesn't match", "comp-panel", cpanel.getAttribute("class")); WebElement dpanel = cpanel.findElement(By.tagName("div")); assertEquals("Component Container table class name doesn't match", "comp-panel dashed-border ui-droppable", dpanel.getAttribute("class")); // TODO Check for component close button /* /* w ww . j a v a2 s . c o m*/ WebElement cbtn = dpanel.findElement(By.className("ctrl-panel")); assertFalse("Close button is still visible", cbtn.isDisplayed()); // Move mouse over and check it visible cbtn = dpanel.findElement(By.className("ui-icon-close")); assertFalse("Close button is visible", cbtn.isDisplayed()); // Move mouse over close button Actions builder = new Actions(driver); builder.moveToElement(cbtn).perform(); assertTrue("Close button is not visible", cbtn.isDisplayed()); */ }
From source file:com.osbitools.ws.shared.prj.xui.GenericPrjMgrGuiWebTest.java
License:LGPL
private List<WebElement> getRevLog(int cnt, int idx) throws InterruptedException { // Open change log checkButtonById(TestConstants.LANG, "ll_change_log", true).click(); WebElement rlog = driver.findElement(By.id("change_log_wrapper")); Thread.sleep(1000);/*from ww w .ja v a 2s .c o m*/ assertTrue("Change Log Wrapper is not visible", rlog.isDisplayed()); // Check revisions WebElement clog = checkElementVisible("change_log_wrapper", true); List<WebElement> rlist = clog.findElement(By.tagName("table")).findElement(By.tagName("tbody")) .findElements(By.tagName("tr")); assertEquals(cnt, rlist.size()); return rlist.get(idx).findElements(By.tagName("td")); }
From source file:com.osbitools.ws.shared.prj.xui.GenericPrjMgrGuiWebTest.java
License:LGPL
private void ctxMenuListClick(WebElement ctx, int idx) { List<WebElement> menu = ctx.findElements(By.tagName("a")); menu.get(idx).click(); }
From source file:com.osbitools.ws.shared.prj.xui.GenericPrjMgrGuiWebTest.java
License:LGPL
/** * Check project widget with/without first entity created * @param lang Test language/*from w w w . ja v a 2s . c o m*/ * @param pname Project name * @param fent True when first entity created */ private void checkProjectWidget(String lang, String pname, boolean fent) { checkLangElementById(lang, "LL_SELECT_PROJECT"); WebElement psel = driver.findElement(By.id("project_sel")); assertEquals(pname, psel.getAttribute("value")); List<WebElement> ops = psel.findElements(By.tagName("option")); assertEquals(1, ops.size()); assertEquals(pname, ops.get(0).getText()); checkLangElementById(lang, "LL_NEW"); checkLangElementById(lang, "LL_RENAME"); checkLangElementById(lang, "LL_DELETE"); checkLangElementById(lang, "LL_GIT_PUSH"); checkLangElementById(lang, "LL_LOGOUT"); // Look for new button WebElement btn = driver.findElement(By.className("node-new-btn")); assertNotNull("New Button is not found", btn); WebElement img = btn.findElement(By.tagName("img")); assertNotNull(img); assertEquals("http://localhost:8090/web_test/fr/" + "modules/prj/images/new_entity.png", img.getAttribute("src")); WebElement bname = btn.findElement(By.tagName("a")); assertNotNull(bname); assertEquals(getLabelText(lang, "LL_NEW"), bname.getText()); assertEquals("pointer", bname.getCssValue("cursor")); // Check list of component groups and icons checkComponentList(lang, fent); // Check project controls disabled checkElementVisible("ws_list", fent); checkElementVisible("entity_ctx_ctrl", fent); if (fent) { checkDataSourceList(lang); checkDbConnList(lang); } }