package ca.corefacility.bioinformatics.irida.ria.integration.pages.analysis;

import java.util.List;

import org.openqa.selenium.By;
import org.openqa.selenium.WebDriver;
import org.openqa.selenium.WebElement;

import ca.corefacility.bioinformatics.irida.ria.integration.pages.AbstractPage;

/**
 * <p> Page Object to represent the Analysis Admin page. </p>
 *
 * @author Josh Adam <josh.adam@phac-aspc.gc.ca>
 */
public class AnalysisAdminPage extends AbstractPage {
	public static final String RELATIVE_URL = "analysis/admin";

	public AnalysisAdminPage(WebDriver driver) {
		super(driver);
		get(driver, RELATIVE_URL);
		waitForTime(700);
	}

	// ************************************************************************************************
	// FINDERS
	// ************************************************************************************************

	public int getTableRowCount() {
		List<WebElement> elements = driver.findElements(By.className("analysis-row"));
		return elements.size();
	}

	// ************************************************************************************************
	// EVENTS
	// ************************************************************************************************

	public void clickShowFilterButton() {
		waitForTime(700);
		driver.findElement(By.id("filterBtn")).click();
		waitForElementVisible(By.id("table-filter"));
	}

	public void filterByName(String name) {
		driver.findElement(By.id("name-filter")).sendKeys(name);
		waitForTime(700);
	}

	public void selectStateFilter(String state) {
		WebElement select = driver.findElement(By.name("state-filter"));
		List<WebElement> options = select.findElements(By.tagName("option"));
		for (WebElement option : options) {
			if (option.getText().equals(state)) {
				option.click();
				waitForTime(700);
				break;
			}
		}
	}

	public void clickClearFilterButton() {
		driver.findElement(By.id("clearFilterBtn")).click();
		waitForTime(700);
	}
}

@@ -1253,36 +1253,39 @@
 n() %7B%0A%09%09
-waitForTime(700);%0A%09%09
+WebElement filterBtn = 
 driver.f
@@ -1306,32 +1306,87 @@
 id(%22filterBtn%22))
+;%0A%09%09waitForElementToBeClickable(filterBtn);%0A%09%09filterBtn
 .click();%0A%09%09wait
@@ -1924,24 +1924,52 @@
 utton() %7B%0A%09%09
+WebElement clearFilterBtn = 
 driver.findE
@@ -1999,16 +1999,81 @@
 erBtn%22))
+;%0A%09%09waitForElementToBeClickable(clearFilterBtn);%0A%09%09clearFilterBtn
 .click()

Update waiting for btns to be clickable