List of usage examples for org.openqa.selenium WebDriver findElements
@Override List<WebElement> findElements(By by);
From source file:org.codelibs.fess.crawler.client.http.action.AOnClickAction.java
License:Apache License
@Override public void collect(final String url, final WebDriver webDriver, final ResponseData responseData) { final List<WebElement> aElementList = webDriver.findElements(By.cssSelector(cssQuery)); for (int i = 0; i < aElementList.size(); i++) { final WebElement aElement = aElementList.get(i); final String onclickAttr = aElement.getAttribute(attrName); if (StringUtil.isNotBlank(onclickAttr)) { final StringBuilder buf = new StringBuilder(url.length() + 30); buf.append(URL_ACTION).append("=").append(name).append("&").append(CSS_QUERY).append("=") .append(cssQuery).append("&").append(INDEX).append("=").append(i); responseData.addChildUrl(/*from w w w . j a v a 2 s .com*/ RequestDataBuilder.newRequestData().get().url(url).metaData(buf.toString()).build()); } } }
From source file:org.codelibs.fess.crawler.client.http.action.FormAction.java
License:Apache License
@Override public void navigate(final WebDriver webDriver, final Map<String, String> paramMap) { final String cssQuery = paramMap.get(CSS_QUERY); final int index = Integer.parseInt(paramMap.get(INDEX)); if (StringUtil.isNotBlank(cssQuery) && index >= 0) { final List<WebElement> elementList = webDriver.findElements(By.cssSelector(cssQuery)); if (index < elementList.size()) { elementList.get(index).submit(); return; }//from w w w.j a v a2s . c o m } throw new CrawlerSystemException("Invalid position. css query: " + cssQuery + ", index: " + index); }
From source file:org.codelibs.fess.crawler.client.http.action.FormAction.java
License:Apache License
@Override public void collect(final String url, final WebDriver webDriver, final ResponseData responseData) { final List<WebElement> formElementList = webDriver.findElements(By.cssSelector(cssQuery)); for (int i = 0; i < formElementList.size(); i++) { final WebElement formElement = formElementList.get(i); final String methodAttr = formElement.getAttribute("method"); String method;//from w w w . j a va 2 s . com if (Constants.GET_METHOD.equalsIgnoreCase(methodAttr)) { method = Constants.GET_METHOD; } else if (Constants.POST_METHOD.equalsIgnoreCase(methodAttr)) { method = Constants.POST_METHOD; } else { method = Constants.GET_METHOD; } final StringBuilder buf = new StringBuilder(url.length() + 30); buf.append(URL_ACTION).append("=").append(name).append("&").append(CSS_QUERY).append("=") .append(cssQuery).append("&").append(INDEX).append("=").append(i); responseData.addChildUrl( RequestDataBuilder.newRequestData().method(method).url(url).metaData(buf.toString()).build()); } }
From source file:org.codelibs.robot.client.http.action.AOnClickAction.java
License:Apache License
@Override public void navigate(final WebDriver webDriver, final Map<String, String> paramMap) { final String cssQuery = paramMap.get(CSS_QUERY); final int index = Integer.parseInt(paramMap.get(INDEX)); if (StringUtil.isNotBlank(cssQuery) && index >= 0) { final List<WebElement> elementList = webDriver.findElements(By.cssSelector(cssQuery)); if (index < elementList.size()) { elementList.get(index).click(); return; }/* w w w.j a va2 s . com*/ } throw new RobotSystemException("Invalid position. css query: " + cssQuery + ", index: " + index); }
From source file:org.codelibs.robot.client.http.action.FormAction.java
License:Apache License
@Override public void navigate(final WebDriver webDriver, final Map<String, String> paramMap) { final String cssQuery = paramMap.get(CSS_QUERY); final int index = Integer.parseInt(paramMap.get(INDEX)); if (StringUtil.isNotBlank(cssQuery) && index >= 0) { final List<WebElement> elementList = webDriver.findElements(By.cssSelector(cssQuery)); if (index < elementList.size()) { elementList.get(index).submit(); return; }//from ww w . ja v a 2 s. co m } throw new RobotSystemException("Invalid position. css query: " + cssQuery + ", index: " + index); }
From source file:org.craftercms.cstudio.share.selenium.basic.AnalyticsTest.java
License:Open Source License
private void test_analytics(WebDriver driver) { // Login/*from w w w. j ava 2 s . c o m*/ CStudioSeleniumUtil.try_login(driver, CStudioSeleniumUtil.MANAGER_USER, CStudioSeleniumUtil.MANAGER_PASSWORD, true); // Navigate to Analytics Dashboard CStudioSeleniumUtil.navigate_to_analytics_dashboard(driver); // Verify Charts List<WebElement> elements = driver.findElements(By.tagName("iframe")); assertTrue(elements.size() == 7); // 7 graphic charts // Wait until at least 1 geo chart is displayed CStudioSeleniumUtil.wait_until_displayed(driver, CStudioSeleniumUtil.SHORT_TIMEOUT, By.tagName("embed")); // Close driver CStudioSeleniumUtil.exit(driver); }
From source file:org.craftercms.cstudio.share.selenium.basic.CStudioSeleniumUtil.java
License:Open Source License
public static void navigate_to_analytics_dashboard(WebDriver driver) { navigate_to(driver, properties.getProperty("acme.analytics.dashboard.url")); // Verify URL assertTrue(driver.getCurrentUrl().equals(properties.getProperty("acme.analytics.dashboard.url"))); // Wait for the page to load new WebDriverWait(driver, LONG_TIMEOUT).until(new ExpectedCondition<Boolean>() { public Boolean apply(WebDriver d) { return d.findElements(By.tagName("iframe")).size() == 7; }//from w w w . ja v a 2s. c o m }); }
From source file:org.craftercms.cstudio.share.selenium.forms.CheckboxGroupSimpleTest.java
License:Open Source License
private void test_checkbox_group_simple(WebDriver driver) { // Login/* ww w. j a v a 2 s. c om*/ CStudioSeleniumUtil.try_login(driver, CStudioSeleniumUtil.AUTHOR_USER, CStudioSeleniumUtil.AUTHOR_PASSWORD, true); // Navigate to Widget CStudioSeleniumUtil.navigate_to_checkbox_group_simple_widget(driver); // Wait until checkboxes are rendered new WebDriverWait(driver, CStudioSeleniumUtil.SHORT_TIMEOUT).until(new ExpectedCondition<Boolean>() { public Boolean apply(WebDriver d) { return d.findElement(By.tagName("body")).getText().contains("From the Inside"); } }); // Verify checkboxes are working fine List<WebElement> elements = driver.findElements(By.className("cstudio-xforms-checkbox-simple-checkbox")); assertEquals(6, elements.size()); for (WebElement e : elements) { e.click(); assertTrue(e.isSelected()); e.click(); assertFalse(e.isSelected()); } // Close driver CStudioSeleniumUtil.exit(driver); }
From source file:org.finra.jtaf.ewd.widget.element.html.RadioGroup.java
License:Apache License
/** * /* w w w . jav a 2s .co m*/ * @return list of web elements found based on all locators * @throws WidgetException */ private List<WebElement> findElements() throws WidgetException { String locator = getLocator(); getGUIDriver().selectLastFrame(); WebDriver wd = getGUIDriver().getWrappedDriver(); List<WebElement> webElements; try { webElements = wd.findElements(By.xpath(locator)); if (webElements != null && webElements.size() > 0) { for (WebElement we : webElements) { highlight(HIGHLIGHT_MODES.FIND); } return webElements; } } catch (Exception e) { } try { webElements = wd.findElements(By.id(locator)); if (webElements != null && webElements.size() > 0) { for (WebElement we : webElements) { highlight(HIGHLIGHT_MODES.FIND); } return webElements; } } catch (Exception e) { } try { webElements = wd.findElements(By.name(locator)); if (webElements != null && webElements.size() > 0) { for (WebElement we : webElements) { highlight(HIGHLIGHT_MODES.FIND); } return webElements; } } catch (Exception e) { } try { webElements = wd.findElements(By.cssSelector(locator)); if (webElements != null && webElements.size() > 0) { for (WebElement we : webElements) { highlight(HIGHLIGHT_MODES.FIND); } return webElements; } } catch (Exception e) { } try { webElements = wd.findElements(By.className(locator)); if (webElements != null && webElements.size() > 0) { for (WebElement we : webElements) { highlight(HIGHLIGHT_MODES.FIND); } return webElements; } } catch (Exception e) { } try { webElements = wd.findElements(By.tagName(locator)); if (webElements != null && webElements.size() > 0) { for (WebElement we : webElements) { highlight(HIGHLIGHT_MODES.FIND); } return webElements; } } catch (Exception e) { } throw new NoSuchElementException("Could not find elements matching " + locator); }
From source file:org.geomajas.gwt2.example.client.LoadsProperlyTestInt.java
License:Open Source License
/** * Simple test which verifies that the demo starts. * /*w ww . ja va 2 s . c o m*/ * @throws Exception oops */ @Test public void testDemoLoadsProperly() throws Exception { WebDriverWait wait = new WebDriverWait(driver, 20); wait.pollingEvery(500, TimeUnit.MILLISECONDS); driver.get("http://localhost:9080/"); // the login window should appear wait.until(new ExpectedCondition<Boolean>() { public Boolean apply(WebDriver d) { return d.findElements(By.className("gwt-ListBox")).size() > 0; } }); }