package pt.fccn.arquivo.tests.util;

import org.openqa.selenium.By;
import org.openqa.selenium.WebDriver;
import org.openqa.selenium.support.ui.ExpectedConditions;
import org.openqa.selenium.support.ui.WebDriverWait;

/**
 *
 * @author Ivo Branco <ivo.branco@fccn.pt>
 *
 */
public class ReplayUtils {

	/**
	 * TODO:: not working in latest Chrome desktop nor in IE 11
	 * Check if textOnReplayPageCheck is visible on replay wayback iframe.
	 *
	 * @param driver
	 * @param textOnReplayPageCheck
	 */
	public static void checkTextOnReplayPage(WebDriver driver, String textOnReplayPageCheck) {
		driver.switchTo().frame("replay_iframe");
		if (textOnReplayPageCheck != null && textOnReplayPageCheck.length() > 0) {			
			new WebDriverWait(driver, 180).until(					
					ExpectedConditions.textToBePresentInElementLocated(By.xpath("/html"), textOnReplayPageCheck));
		}
		driver.switchTo().defaultContent();
	}
}

@@ -30,16 +30,126 @@
 .util;%0A%0A
+import static org.hamcrest.CoreMatchers.containsString;%0Aimport static org.hamcrest.MatcherAssert.assertThat;%0A%0A
 import o
@@ -209,16 +209,63 @@
 Driver;%0A
+import org.openqa.selenium.WebDriverException;%0A
 import o
@@ -745,16 +745,128 @@
 ck) %7B%0A%09%09
+new WebDriverWait(driver, 180).until(ExpectedConditions.frameToBeAvailableAndSwitchToIt(%22replay_iframe%22));%0A%09%09// 
 driver.s
@@ -975,20 +975,28 @@
 ) %3E 0) %7B
+%0A%0A
 %09%09%09
-%0A
+try %7B%0A%09
 %09%09%09new W
@@ -1027,21 +1027,16 @@
 ).until(
-%09%09%09%09%09
 %0A%09%09%09%09%09Ex
@@ -1091,24 +1091,357 @@
 (By.
-xpath(%22/html%22), 
+tagName(%22body%22), textOnReplayPageCheck));%0A%09%09%09%7D catch (WebDriverException e) %7B%0A%09%09%09%09System.out.println(%22ReplayUtils.checkTextOnReplayPage error when waiting text to be visible using fall back to check content is visible.%22);%0A%09%09%09%09driver.switchTo().defaultContent();%0A%0A%09%09%09%09assertThat(driver.findElement(By.tagName(%22body%22)).getText(),%0A%09%09%09%09%09%09containsString(
 text
@@ -1461,16 +1461,21 @@
 heck));%0A
+%09%09%09%7D%0A
 %09%09%7D%0A%09%09dr

Improve replay utils