package me.alb_i986.selenium.tinafw.pages;

import org.openqa.selenium.By;
import org.openqa.selenium.WebDriver;
import org.openqa.selenium.WebElement;
import org.openqa.selenium.support.ui.ExpectedCondition;

public class TinafwExpectedConditions {

	protected TinafwExpectedConditions() {
	}

	/**
	 * An expectation for checking that at least one of the elements matching the locator
	 * is visible.
	 *
	 * @param locator used to find the elements
	 * @return the first visible WebElement that is found
	 */
	public static ExpectedCondition<WebElement> visibilityOfOneOfElementsLocatedBy(final By locator) {
		return new ExpectedCondition<WebElement>() {
			@Override
			public WebElement apply(WebDriver driver) {
				for (WebElement element : driver.findElements(locator)) {
					if (element.isDisplayed()) {
						return element;
					}
				}
				return null;
			}

			@Override
			public String toString() {
				return "visibility of one of the elements located by " + locator;
			}
		};
	}
}

@@ -992,10 +992,498 @@
 %09%09%7D;%0A%09%7D%0A
+%0A%09/**%0A%09 * Expectation for checking that %7B@link WebDriver#getCurrentUrl()%7D is not empty.%0A%09 * %0A%09 * @return %3Ccode%3Etrue%3C/code%3E if WebDriver#getCurrentUrl is not empty%0A%09 */%0A%09public static ExpectedCondition%3CBoolean%3E currentUrlIsNotEmpty() %7B%0A%09%09return new ExpectedCondition%3CBoolean%3E() %7B%0A%09%09%09@Override%0A%09%09%09public Boolean apply(WebDriver driver) %7B%0A%09%09%09%09return !driver.getCurrentUrl().equals(%22%22);%0A%09%09%09%7D%0A%0A%09%09%09@Override%0A%09%09%09public String toString() %7B%0A%09%09%09%09return %22current URL to be not empty%22;%0A%09%09%09%7D%0A%09%09%7D;%0A%09%7D%0A%0A
 %7D%0A

add ExpectedCondition currentUrlIsNotEmpty