package pt.fccn.mobile.arquivo.tests.imagesearch;

import static org.hamcrest.CoreMatchers.containsString;
import static org.hamcrest.MatcherAssert.assertThat;

import org.junit.Test;
import org.openqa.selenium.By;

import pt.fccn.arquivo.selenium.Retry;
import pt.fccn.arquivo.selenium.WebDriverTestBaseParalell;

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

	public ImageSearchQuerySuggestionTest(String os, String version, String browser, String deviceName,
			String deviceOrientation) {
		super(os, version, browser, deviceName, deviceOrientation);
	}

	@Test
	@Retry
	public void imageSearchQuerySuggestionTest() {
		run("Search with testre", () -> {
			driver.findElement(By.id("txtSearch")).clear();
			driver.findElement(By.id("txtSearch")).sendKeys("testre");
			driver.findElement(By.xpath("//*[@id=\"buttonSearch\"]/button")).click();
		});

		run("Search images instead of text", () -> {
			waitUntilElementIsVisibleAndGet(By.id("ImageButton")).click();
		});

		assertThat("Verify if a suggestion is presented",
				driver.findElement(By.xpath("//*[@class=\"suggestion\"]/a")).getText(), containsString("teste"));
	}

}

@@ -1,8 +1,10 @@
+//
 package 
@@ -45,17 +45,21 @@
 search;%0A
-%0A
+//%0A//
 import s
@@ -106,16 +106,18 @@
 String;%0A
+//
 import s
@@ -161,17 +161,21 @@
 rtThat;%0A
-%0A
+//%0A//
 import o
@@ -189,16 +189,18 @@
 t.Test;%0A
+//
 import o
@@ -222,17 +222,21 @@
 ium.By;%0A
-%0A
+//%0A//
 import p
@@ -266,16 +266,18 @@
 .Retry;%0A
+//
 import p
@@ -331,16 +331,24 @@
 ll;%0A
-%0A
+//%0A//
 /**%0A
+//
  *%0A
+//
  * @
@@ -390,15 +390,21 @@
 pt%3E%0A
+//
  *%0A
+//
  */%0A
+//
 publ
@@ -479,17 +479,21 @@
 alell %7B%0A
-%0A
+//%0A//
 %09public 
@@ -585,16 +585,18 @@
 ceName,%0A
+//
 %09%09%09Strin
@@ -618,16 +618,18 @@
 tion) %7B%0A
+//
 %09%09super(
@@ -686,27 +686,35 @@
 n);%0A
+//
 %09%7D%0A
-%0A
+//%0A//
 %09@Test%0A
+//
 %09@Retry%0A
 %09pub
@@ -709,16 +709,18 @@
 %09@Retry%0A
+//
 %09public 
@@ -759,16 +759,18 @@
 est() %7B%0A
+//
 %09%09run(%22S
@@ -797,16 +797,18 @@
 () -%3E %7B%0A
+//
 %09%09%09drive
@@ -850,16 +850,18 @@
 lear();%0A
+//
 %09%09%09drive
@@ -914,16 +914,18 @@
 stre%22);%0A
+//
 %09%09%09drive
@@ -993,23 +993,29 @@
 lick();%0A
+//
 %09%09%7D);%0A
-%0A
+//%0A//
 %09%09run(%22S
@@ -1053,16 +1053,18 @@
 () -%3E %7B%0A
+//
 %09%09%09waitU
@@ -1125,15 +1125,21 @@
 ();%0A
+//
 %09%09%7D);%0A
-%0A
+//%0A//
 %09%09as
@@ -1186,16 +1186,18 @@
 ented%22,%0A
+//
 %09%09%09%09driv
@@ -1294,10 +1294,16 @@
 ));%0A
+//
 %09%7D%0A
-%0A
+//%0A//
 %7D%0A

Comment image search query suggestion test until arquivo/pwa-technologies#602 is fixed.