import static junit.framework.Assert.assertTrue;

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

public class TestWaveJS  {
  public static void main(String[] args) {
    try {
      // Create a new instance of the Firefox driver
      // Notice that the remainder of the code relies on the interface,
      // not the implementation.
      WebDriver driver = new ChromeDriver();
  
      (new WebDriverWait(driver, 180)).until(new ExpectedCondition<Boolean>() {
        public Boolean apply(WebDriver d) {
          d.get("http://localhost:9898/test/wavejs.html");
  
          return d.findElement(By.id("loginForm")).isDisplayed();
        }
      });
  
      // Find the text input element by its name
      WebElement uid = driver.findElement(By.id("uid"));
  
      // Enter something to search for
      uid.sendKeys("test");
  
      WebElement pwd = driver.findElement(By.id("password"));
  
      pwd.sendKeys("test");
  
      // Now submit the form. WebDriver will find the form for us from the element
      uid.submit();
  
      // Check the title of the page
      //System.out.println("Page title is: " + driver.getTitle());
  
      // login
      driver.findElement(By.id("login")).click();
  
      // Wait for the page to load, timeout after 10 seconds
      (new WebDriverWait(driver, 10)).until(new ExpectedCondition<Boolean>() {
        public Boolean apply(WebDriver d) {
          return d.findElement(By.id("logoutForm")).isDisplayed();
        }
      });
  
      // run test suite
      driver.findElement(By.id("runP2PvalueTest")).click();
  
      // Wait for the page to load, timeout after 10 seconds
      (new WebDriverWait(driver, 60)).until(new ExpectedCondition<Boolean>() {
        public Boolean apply(WebDriver d) {
          return d.findElement(By.cssSelector("div.results")).isDisplayed();
        }
      });

      System.out.println("Failures: ");
      System.out.println(driver.findElement(By.cssSelector("div.failures")).getText());

      assertTrue(driver.findElement(By.cssSelector("span.bar.passed")).isDisplayed());
    } finally {
      // Close the browser
      driver.quit();
    }
  }
}

@@ -589,27 +589,25 @@
 meDriver();%0A
-  
 %0A
+
       (new W
@@ -773,27 +773,25 @@
 ejs.html%22);%0A
-  
 %0A
+
           re
@@ -856,35 +856,33 @@
     %7D%0A      %7D);%0A
-  
 %0A
+
       // Find th
@@ -967,27 +967,25 @@
 id(%22uid%22));%0A
-  
 %0A
+
       // Ent
@@ -1031,30 +1031,38 @@
 ndKeys(%22test
+@local.net
 %22);%0A
-  
 %0A      WebEl
@@ -1108,27 +1108,25 @@
 assword%22));%0A
-  
 %0A
+
       pwd.se
@@ -1141,19 +1141,17 @@
 test%22);%0A
-  
 %0A
+
       //
@@ -1241,27 +1241,25 @@
 d.submit();%0A
-  
 %0A
+
       // Che
@@ -1350,19 +1350,17 @@
 tle());%0A
-  
 %0A
+
       //
@@ -1408,35 +1408,33 @@
 gin%22)).click();%0A
-  
 %0A
+
       // Wait fo
@@ -1688,19 +1688,17 @@
     %7D);%0A
-  
 %0A
+
       //
@@ -1773,18 +1773,16 @@
 lick();%0A
-  
 %0A      /

Test login with domain in user ID field