Checks a selenium list of WebElements.

@param commong common object that contains relevant execution info
@param actual webElement used in assert
@return SeleniumAssert
191263
public static SeleniumAssert assertThat(CommonG commong, List<WebElement> actual) {
        return new SeleniumAssert(commong, actual);
    }
1178792
@When("^I clear the content on text input at index '(\\d+?)'$")
    public void seleniumClear(Integer index) {
        assertThat(this.commonspec, commonspec.getPreviousWebElements()).as("There are less found elements than required")
                .hasAtLeast(index);

        assertThat(this.commonspec, commonspec.getPreviousWebElements().getPreviousWebElements().get(index)).isTextField(commonspec.getTextFieldCondition());

        commonspec.getPreviousWebElements().getPreviousWebElements().get(index).clear();
    }
1023370
public static ExpectedCondition<List<WebElement>> visibilityOfFirstElements(final By locator) {
        return new ExpectedCondition<List<WebElement>>() {
            @Override
            public List<WebElement> apply(final WebDriver driver) {
                return getFirstVisibleWebElements(driver, null, locator);
            }

            @Override
            public String toString() {
                return String.format("visibility of element located by %s", locator);
            }
        };
    }
1311444
static boolean containsMatch(String actual, String regex) {
    return Pattern.compile(regex).matcher(actual).find();
  }
616322
private boolean checkElement(final StartElement mEvent) throws TTIOException {
        assert mEvent != null;
        boolean retVal = false;

        // Matching element names?
        if (mWtx.getNode().getKind() == IConstants.ELEMENT
            && mWtx.getQNameOfCurrentNode().equals(mEvent.getName())) {
            // Check if atts and namespaces are the same.
            final long nodeKey = mWtx.getNode().getDataKey();

            // Check attributes.
            boolean foundAtts = false;
            boolean hasAtts = false;
            for (final Iterator<?> it = mEvent.getAttributes(); it.hasNext();) {
                hasAtts = true;
                final Attribute attribute = (Attribute)it.next();
                for (int i = 0, attCount = ((ElementNode)mWtx.getNode()).getAttributeCount(); i < attCount; i++) {
                    mWtx.moveToAttribute(i);
                    if (attribute.getName().equals(mWtx.getQNameOfCurrentNode())
                        && attribute.getValue().equals(mWtx.getValueOfCurrentNode())) {
                        foundAtts = true;
                        mWtx.moveTo(nodeKey);
                        break;
                    }
                    mWtx.moveTo(nodeKey);
                }

                if (!foundAtts) {
                    break;
                }
            }
            if (!hasAtts && ((ElementNode)mWtx.getNode()).getAttributeCount() == 0) {
                foundAtts = true;
            }

            // Check namespaces.
            boolean foundNamesps = false;
            boolean hasNamesps = false;
            for (final Iterator<?> namespIt = mEvent.getNamespaces(); namespIt.hasNext();) {
                hasNamesps = true;
                final Namespace namespace = (Namespace)namespIt.next();
                for (int i = 0, namespCount = ((ElementNode)mWtx.getNode()).getNamespaceCount(); i < namespCount; i++) {
                    mWtx.moveToNamespace(i);
                    final ITreeNameData namenode = (ITreeNameData)mWtx.getNode();
                    if (namespace.getNamespaceURI().equals(mWtx.nameForKey(namenode.getURIKey()))
                        && namespace.getPrefix().equals(mWtx.nameForKey(namenode.getNameKey()))) {
                        foundNamesps = true;
                        mWtx.moveTo(nodeKey);
                        break;
                    }
                    mWtx.moveTo(nodeKey);
                }

                if (!foundNamesps) {
                    break;
                }
            }
            if (!hasNamesps && ((ElementNode)mWtx.getNode()).getNamespaceCount() == 0) {
                foundNamesps = true;
            }

            // Check if atts and namespaces are the same.
            if (foundAtts && foundNamesps) {
                retVal = true;
            } else {
                retVal = false;
            }
        }

        return retVal;
    }
370636
public static ExpectedCondition<Boolean> javaScriptThrowsNoExceptions(final String javaScript) {
    return new ExpectedCondition<Boolean>() {
      @Override
      public Boolean apply(WebDriver driver) {
        try {
          ((JavascriptExecutor) driver).executeScript(javaScript);
          return true;
        } catch (WebDriverException e) {
          return false;
        }
      }

      @Override
      public String toString() {
        return String.format("js %s to be executable", javaScript);
      }
    };
  }
588195
public SeleniumAssert contains(CharSequence... values) {
        if (actual instanceof WebDriver) {
            Strings.instance().assertContains(info,
                    ((WebDriver) actual).getPageSource(), values);
        } else if (actual instanceof WebElement) {
            Strings.instance().assertContains(info,
                    ((WebElement) actual).getText(), values);
        }
        return this;
    }
810936
public <T> void assertThat(T actual, org.hamcrest.Matcher<? super T> matcher) {
    try {
      org.hamcrest.MatcherAssert.assertThat(actual, matcher);
    } catch (AssertionError e) {
      fail(e);
    }
  }
699185
public void assertText(final By by, final String text) {
		WebElement element = driver.findElement(by);

		Assert.assertEquals("Element: " + element
				+ " does NOT contain the given text: " + text, text,
				element.getText());
	}
962198
public static <T> BindingAssert<T> assertThat(Binding<T> actual) {
        return new BindingAssert<T>(actual);
    }
1106412
@Override
	public List<WebElement> findElements(final By by) {
		return wef.by(by).findAll();
	}
284703
def assert_visible(self, locator, msg=None):
        
        e = driver.find_elements_by_locator(locator)
        if len(e) == 0:
            raise AssertionError("Element at %s was not found" % locator)
        assert e.is_displayed()
429321
public static ExpectedCondition<WebElement> elementToBeClickable(final WebElement element) {
    return new ExpectedCondition<WebElement>() {

      @Override
      public WebElement apply(WebDriver driver) {
        WebElement visibleElement = visibilityOf(element).apply(driver);
        try {
          if (visibleElement != null && visibleElement.isEnabled()) {
            return visibleElement;
          }
          return null;
        } catch (StaleElementReferenceException e) {
          return null;
        }
      }

      @Override
      public String toString() {
        return "element to be clickable: " + element;
      }
    };
  }
860604
public static ExpectedCondition<Boolean> invisibilityOfElementLocated(final By locator) {
    return new ExpectedCondition<Boolean>() {
      @Override
      public Boolean apply(WebDriver driver) {
        try {
          return !(driver.findElement(locator).isDisplayed());
        } catch (NoSuchElementException e) {
          // Returns true because the element is not present in DOM. The
          // try block checks if the element is present but is invisible.
          return true;
        } catch (StaleElementReferenceException e) {
          // Returns true because stale element reference implies that element
          // is no longer visible.
          return true;
        }
      }

      @Override
      public String toString() {
        return "element to no longer be visible: " + locator;
      }
    };
  }
47413
private static List<String> gridBrowsers(Map<String, String> filter) {

        ArrayList<String> response = new ArrayList<String>();
        LOGGER.debug("Trying to get a list of Selenium-available browsers");

        String grid = System.getProperty("SELENIUM_GRID");

        if (grid != null) {
            grid = "http://" + grid + "/grid/console";
            Document doc;
            try {
                doc = Jsoup.connect(grid).timeout(DEFAULT_TIMEOUT).get();
            } catch (IOException e) {
                LOGGER.debug("Exception on connecting to Selenium grid: {}", e.getMessage());
                return response;
            }

            Elements slaves = (Elements) doc.select("div.proxy");

            for (Element slave : slaves) {
                String slaveStatus = slave.select("p.proxyname").first().text();
                if (!slaveStatus.contains("Connection") && !slaveStatus.contains("Conexión")) {
                    Integer iBusy = 0;
                    Elements browserList = slave.select("div.content_detail").select("*[title]");
                    Elements busyBrowserList = slave.select("div.content_detail").select("p > .busy");
                    for (Element browserDetails : browserList) {
                        if (browserDetails.attr("title").startsWith("{")) {
                            boolean filterCheck = true;
                            for (Map.Entry<String, String> f : filter.entrySet()) {
                                String stringFilter = f.getKey() + "=" + f.getValue() + "[,|}]";
                                Pattern patFilter = Pattern.compile(stringFilter);
                                Matcher mFilter = patFilter.matcher(browserDetails.attr("title"));
                                filterCheck = filterCheck & mFilter.find();
                            }
                            if (filterCheck) {
                                Pattern pat = Pattern.compile("browserName=(.*?),.*?(version=(.*?)[,|}])");
                                Matcher m = pat.matcher(browserDetails.attr("title"));
                                while (m.find()) {
                                    String browser = m.group(1) + "_" + m.group(3);
                                    if (browser.equals(System.getProperty("FORCE_BROWSER"))) {
                                        response.add(browser);
                                    }
                                }
                            }
                        } else {
                            String version = busyBrowserList.get(iBusy).parent().text();
                            String browser = busyBrowserList.get(iBusy).text();
                            version = version.substring(2);
                            version = version.replace(browser, "");
                            String browserSrc = busyBrowserList.get(iBusy).select("img").attr("src");
                            if (!browserSrc.equals("")) {
                                browser = browserSrc.substring(browserSrc.lastIndexOf('/') + 1, browserSrc.length()
                                        - DEFAULT_LESS_LENGTH);
                            }
                            response.add(browser + "_" + version);
                            iBusy++;
                        }
                    }
                }
            }
        }
        // Sort response
        Collections.sort(response);
        return response;
    }
549314
@When("^I delete the text '(.+?)' on the element on index '(\\d+?)'( and replace it for '(.+?)')?$")
    public void seleniumDelete(String text, Integer index, String foo, String replacement) {
        assertThat(this.commonspec, commonspec.getPreviousWebElements()).as("There are less found elements than required")
                .hasAtLeast(index);

        Actions actions = new Actions(commonspec.getDriver());
        actions.moveToElement(commonspec.getPreviousWebElements().getPreviousWebElements().get(index), (text.length() / 2), 0);
        for (int i = 0; i < (text.length() / 2); i++) {
            actions.sendKeys(Keys.ARROW_LEFT);
            actions.build().perform();
        }
        for (int i = 0; i < text.length(); i++) {
            actions.sendKeys(Keys.DELETE);
            actions.build().perform();
        }
        if (replacement != null && replacement.length() != 0) {
            actions.sendKeys(replacement);
            actions.build().perform();
        }
    }
172843
public List<WebElement> findAll() {
		checkState(webDriver != null, "No WebDriver specified.");
		checkState(by != null, "No By instance for locating elements specified.");

		log.info(toString());

		final List<WebElement> result = newArrayList();

		try {
			if (timeoutSeconds > 0L) {
				WebDriverWait wait = createWebDriverWait();
				wait.until(new Function<WebDriver, List<WebElement>>() {
					@Override
					public List<WebElement> apply(final WebDriver input) {
						doFindElements(result, input);
						if (result.isEmpty()) {
							// this means, we try again until the timeout occurs
							throw new WebElementException("No matching element found.");
						}
						return result;
					}

					@Override
					public String toString() {
						return WebElementFinder.this.toString();
					}
				});
			} else {
				doFindElements(result, webDriver);
			}
			return result;
		} catch (TimeoutException ex) {
			Throwable cause = ex.getCause();
			for (Class<? extends Throwable> thClass : IGNORED_EXCEPTIONS) {
				if (thClass.isInstance(cause)) {
					return ImmutableList.of();
				}
			}
			throw new WebElementException(ex);
		}
	}