List of usage examples for org.openqa.selenium By tagName
public static By tagName(String tagName)
From source file:com.fireblade.qa.automation.modelbusinesslogic.FooterBI.java
private void getLinksFromSectionAndClickOnFirstLink(WebElementWrapper section) throws Exception { List<WebElement> allLinks = section.get().findElements(By.tagName("a")); if (allLinks.size() > 0) { allLinks.get(0).click();/*from w w w. ja v a 2 s .co m*/ } }
From source file:com.fmb.common.BrowserEmulator.java
License:Apache License
public WebElement getTable(int index) { WebElement element = null;/*from w ww . j a v a 2 s .co m*/ if (this.isElementExist(By.tagName("table"))) { element = browserCore.findElements(By.tagName("table")).get(index); } return element; }
From source file:com.formkiq.web.OAuthFederationIntegrationTest.java
License:Apache License
/** * testOauth02()./* w w w . j av a 2 s.c om*/ * add oauth federation * * @throws Exception Exception */ @Test public void testOauth02() throws Exception { // given // when findElementBy(By.id("oauth_add_button")).click(); getWait().until(ExpectedConditions.visibilityOfElementLocated(By.id("form-modal"))); findElementBy("input", "data-valuekey", "domain").sendKeys("222"); findElementBy("input", "data-valuekey", "username").sendKeys("333"); findElementBy("input", "data-valuekey", "host").sendKeys("444"); click(By.name("_eventId_next")); // then getWait().until(ExpectedConditions.invisibilityOfElementLocated(By.id("form-modal"))); assertEquals(1, getTableRowCount("results")); List<WebElement> tablecells = findElements(By.tagName("td")); assertRowEquals(tablecells, Arrays.asList("333", "444", "")); // when findElementBy(By.id("delete_0")).click(); // then assertNoOAuthSetup(); }
From source file:com.formkiq.web.OAuthFederationIntegrationTest.java
License:Apache License
/** * testOauth03().//from w w w . ja v a2 s. c o m * add oauth federation, domain only * * @throws Exception Exception */ @Test public void testOauth03() throws Exception { // given // when findElementBy(By.id("oauth_add_button")).click(); getWait().until(ExpectedConditions.visibilityOfElementLocated(By.id("form-modal"))); findElementBy("input", "data-valuekey", "domain").sendKeys("222"); findElementBy("input", "data-valuekey", "host").sendKeys("444"); click(By.name("_eventId_next")); // then getWait().until(ExpectedConditions.invisibilityOfElementLocated(By.id("form-modal"))); assertEquals(1, getTableRowCount("results")); List<WebElement> tablecells = findElements(By.tagName("td")); assertRowEquals(tablecells, Arrays.asList("222", "444", "")); // when findElementBy(By.id("delete_0")).click(); // then assertNoOAuthSetup(); }
From source file:com.formkiq.web.UserSeleniumTest.java
License:Apache License
/** * testUsers02()./*from ww w . jav a 2 s . c o m*/ * Add User * * @throws Exception Exception */ @Test public void testUsers02() throws Exception { // given String email = "test2@formkiq.com"; // when findElementBy(By.id("user_add_button")).click(); getWait().until(ExpectedConditions.visibilityOfElementLocated(By.id("form-modal"))); findElementBy("input", "data-valuekey", "email").sendKeys(email); // then assertEquals("ROLE_USER", getSelectedValue(findElementBy("select", "data-valuekey", "role"))); assertEquals("ACTIVE", getSelectedValue(findElementBy("select", "data-valuekey", "status"))); WebElement el = findElementBy(By.name("_eventId_next")); assertEquals("Add User", el.getText()); // when el.click(); // then getWait().until(ExpectedConditions.invisibilityOfElementLocated(By.id("form-modal"))); assertEquals(2, getTableRowCount("results")); List<WebElement> cells = findElements(By.tagName("td")); WebElement e = cells.stream().filter(s -> s.getText().contains(email)).findFirst().get(); int index = cells.indexOf(e); assertEquals("test2@formkiq.com", e.getText()); assertEquals("ROLE_USER", cells.get(index + 1).getText()); assertEquals("INVITE", cells.get(index + 2).getText()); // when click(By.id("edit_" + getDefaultEmail())); // then getWait().until(ExpectedConditions.visibilityOfElementLocated(By.id("form-modal"))); el = findElementBy(By.name("_eventId_next")); assertEquals("Update User", el.getText()); assertEquals(getDefaultEmail(), findElementBy("input", "data-valuekey", "email").getAttribute("value")); assertFalse(getDriver().findElement(getBy("input", "data-valuekey", "password")).isDisplayed()); assertFalse(getDriver().findElement(getBy("input", "data-valuekey", "confirmpassword")).isDisplayed()); assertEquals("ROLE_ADMIN", getSelectedValue(findElementBy("select", "data-valuekey", "role"))); assertEquals("ACTIVE", getSelectedValue(findElementBy("select", "data-valuekey", "status"))); LoggerMailSender l = (LoggerMailSender) this.mail.getMailSender(); assertEquals(0, l.getMessages().size()); assertEquals(1, l.getMimeMessages().size()); MimeMessage m = l.getMimeMessages().get(0); Multipart mp = (Multipart) m.getContent(); assertEquals(2, mp.getCount()); MimeBodyPart part = (MimeBodyPart) mp.getBodyPart(0); assertNull(m.getFrom()); assertEquals(email, String.join(",", Arrays.asList(m.getRecipients(Message.RecipientType.TO)).stream() .map(s -> s.toString()).collect(Collectors.toList()))); assertEquals("Welcome to FormKiQ", m.getSubject()); assertTrue(part.getContent().toString() .contains(getDefaultHostAndPort() + "/register?email=" + email + "&resettoken=")); // given logout(); String url = extractUrl(part.getContent().toString()); // when getDriver().navigate().to(url); // then assertEquals("FormKiQ Server - User Registration", getTitle()); // given // when findElementBy(By.name("password")).sendKeys(getDefaultPass()); findElementBy(By.name("confirmpassword")).sendKeys(getDefaultEmail()); click(By.name("_eventId_next")); // then waitUntilPageSourceText("Passwords do not match"); // given // when findElementBy(By.name("password")).clear(); findElementBy(By.name("confirmpassword")).clear(); findElementBy(By.name("password")).sendKeys(getDefaultPass()); findElementBy(By.name("confirmpassword")).sendKeys(getDefaultPass()); click(By.name("_eventId_next")); // then waitUntilPageSourceText("Registration is complete"); // when login(email); // then assertEquals("FormKiQ Server - Dashboard", getTitle()); }
From source file:com.fpt.datht.iap.AutoIAP.java
public static void getDataFromServer(String className) { int c = 0;/* w w w . j av a 2 s . c om*/ slots = new String[10]; students = new LinkedList<>(); new WebDriverWait(driver, 360).until(ExpectedConditions.titleIs("IAP")); driver.get("http://iap.fpt.edu.vn/activity"); new WebDriverWait(driver, 360).until(ExpectedConditions.urlToBe("http://iap.fpt.edu.vn/activity/")); List<WebElement> els = driver.findElements(By.tagName("a")); System.out.println("Size a:" + els.size()); for (WebElement e : els) { // System.out.println(e.getText()); if (e.getText().contains(className)) { slots[c] = e.getAttribute("href").replaceAll("http://iap.fpt.edu.vn/activity/index.php", "http://iap.fpt.edu.vn/attendance/add.php"); c++; count = c; // System.out.println(main); } } if (slots.length == 0) return; driver.get(slots[0]); try { new WebDriverWait(driver, 5) .until(ExpectedConditions.presenceOfElementLocated(By.xpath(".//input[@type='submit']"))); } catch (TimeoutException ex) { driver.get(slots[0].replaceAll("add.php", "edit.php")); } //Auto Check Slot 1 if (autoCheckSlot1) { List<WebElement> elsInput = driver.findElements(By.xpath(".//input[@type='radio' and @value='1' ]")); autoCheckAll(elsInput); } //Wating for submit new WebDriverWait(driver, 5000) .until(ExpectedConditions.presenceOfElementLocated(By.xpath(".//font[@color='green']"))); driver.get(slots[0].replaceAll("add.php", "edit.php")); //GET All checked List<WebElement> elsInputChecked = driver .findElements(By.xpath(".//input[@type='radio' and @value='1' and @checked]")); System.out.println("Size input checked:" + elsInputChecked.size()); elsInputChecked.stream().map((e) -> { Student student = new Student(); student.name = e.getAttribute("name"); return student; }).forEach(students::add); }
From source file:com.francetelecom.clara.cloud.webapp.acceptancetest.pages.ApplicationCreationPage.java
License:Apache License
public ApplicationCreationPage(WebDriver wd) { super(wd);/* www . ja v a 2 s . c o m*/ logger.debug("current url is : " + wd.getCurrentUrl()); logger.debug("page title : " + wd.getTitle()); // assert that we are on the right page SeleniumUtils.waitForElement(wd, "addAppButton", DEFAULT_AJAX_TIMEOUT); if (!wd.findElement(By.tagName("html")).getText().contains("create application")) { throw new IllegalStateException("this is not the new application page"); } logger.debug("you are in application creation page"); }
From source file:com.francetelecom.clara.cloud.webapp.acceptancetest.pages.EnvironmentCreationPage.java
License:Apache License
public EnvironmentCreationPage(WebDriver wd) throws InterruptedException { super(wd);/*from w ww. j a v a 2 s . c o m*/ logger.debug("current url is : " + wd.getCurrentUrl()); logger.debug("page title : " + wd.getTitle()); // assert that we are on the right page create environment SeleniumUtils.waitForElement(wd, "addEnvButton", DEFAULT_AJAX_TIMEOUT); if (!wd.findElement(By.tagName("html")).getText().contains("create environment")) { logger.error( "This should contains 'create environment'" + wd.findElement(By.tagName("html")).getText()); throw new IllegalStateException("this is not the new environment page"); } logger.debug("you are in create environment page"); }
From source file:com.francetelecom.clara.cloud.webapp.acceptancetest.utils.SeleniumUtils.java
License:Apache License
/*** * Gets select option by xpath//ww w . j a v a 2 s.com * * @param driver * @param nameOrID * @param optionXPath * @return */ public static WebElement getSelectOptionByXPath(WebDriver driver, String nameOrID, String optionXPath) { WebElement selectElement = getByNameOrID(driver, nameOrID); WebElement options = selectElement.findElement(By.tagName("option")); return selectElement.findElement(By.xpath(optionXPath)); }
From source file:com.galenframework.ide.tests.integration.components.galenpages.WebComponent.java
License:Apache License
@SuppressWarnings("unchecked") public T selectByText(String text) { WebElement webElement = getWebElement(); Optional<WebElement> optionElement = webElement.findElements(By.tagName("option")).stream() .filter(e -> text.equals(e.getText())).findFirst(); if (optionElement.isPresent()) { optionElement.get().click();/*from w w w . j av a 2 s.co m*/ } else { throw new RuntimeException("Couldn't find option with text \"" + text + "\" for " + getName()); } return (T) this; }