package com.lazerycode.selenium.Tests;

import com.lazerycode.selenium.SeleniumBase;
import com.lazerycode.selenium.ScreenshotListener;
import org.openqa.selenium.By;
import org.openqa.selenium.WebDriver;
import org.openqa.selenium.WebElement;
import org.openqa.selenium.support.ui.ExpectedCondition;
import org.openqa.selenium.support.ui.WebDriverWait;
import org.testng.annotations.Listeners;
import org.testng.annotations.Test;

@Listeners(ScreenshotListener.class)
public class Selenium2ExampleST extends SeleniumBase {

  @Test
  public void googleCheeseExample() {
    // Create a new WebDriver instance
    // Notice that the remainder of the code relies on the interface,
    // not the implementation.
    WebDriver driver = getDriver();

    // And now use this to visit Google
    driver.get("http://www.google.com");
    // Alternatively the same thing can be done like this
    // driver.navigate().to("http://www.google.com");

    // Find the text input element by its name
    WebElement element = driver.findElement(By.name("q"));

    // Enter something to search for
    element.sendKeys("Cheese!");

    // Now submit the form. WebDriver will find the form for us from the element
    element.submit();

    // Check the title of the page
    System.out.println("Page title is: " + driver.getTitle());

    // Google's search is rendered dynamically with JavaScript.
    // 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.getTitle().toLowerCase().startsWith("Cheese!");
      }
    });

    // Should see: "cheese! - Google Search"
    System.out.println("Page title is: " + driver.getTitle());

    //Close the browser
    driver.quit();
  }
}
@@ -31,19 +31,17 @@
 m.Tests;
-%0D%0A%0D
+%0A
 %0Aimport 
@@ -77,17 +77,16 @@
 iumBase;
-%0D
 %0Aimport 
@@ -128,17 +128,16 @@
 istener;
-%0D
 %0Aimport 
@@ -159,17 +159,16 @@
 nium.By;
-%0D
 %0Aimport 
@@ -197,17 +197,16 @@
 bDriver;
-%0D
 %0Aimport 
@@ -236,17 +236,16 @@
 Element;
-%0D
 %0Aimport 
@@ -293,17 +293,16 @@
 ndition;
-%0D
 %0Aimport 
@@ -346,17 +346,16 @@
 verWait;
-%0D
 %0Aimport 
@@ -387,17 +387,16 @@
 steners;
-%0D
 %0Aimport 
@@ -423,19 +423,17 @@
 ns.Test;
-%0D%0A%0D
+%0A
 %0A@Listen
@@ -461,17 +461,16 @@
 r.class)
-%0D
 %0Apublic 
@@ -520,19 +520,17 @@
 se %7B
-%0D%0A%0D
+%0A
 %0A  @Test
 %0D%0A  
@@ -525,17 +525,16 @@
 %0A  @Test
-%0D
 %0A  publi
@@ -559,25 +559,24 @@
 eExample() %7B
-%0D
 %0A    // Crea
@@ -602,17 +602,16 @@
 instance
-%0D
 %0A    // 
@@ -672,17 +672,16 @@
 terface,
-%0D
 %0A    // 
@@ -703,17 +703,16 @@
 ntation.
-%0D
 %0A    Web
@@ -739,19 +739,17 @@
 river();
-%0D%0A%0D
+%0A
 %0A    // 
@@ -780,17 +780,16 @@
 t Google
-%0D
 %0A    dri
@@ -821,17 +821,16 @@
 e.com%22);
-%0D
 %0A    // 
@@ -879,17 +879,16 @@
 ike this
-%0D
 %0A    // 
@@ -933,19 +933,17 @@
 e.com%22);
-%0D%0A%0D
+%0A
 %0A    // 
@@ -981,17 +981,16 @@
 its name
-%0D
 %0A    Web
@@ -1040,19 +1040,17 @@
 e(%22q%22));
-%0D%0A%0D
+%0A
 %0A    // 
@@ -1078,17 +1078,16 @@
 arch for
-%0D
 %0A    ele
@@ -1111,19 +1111,17 @@
 eese!%22);
-%0D%0A%0D
+%0A
 %0A    // 
@@ -1193,17 +1193,16 @@
  element
-%0D
 %0A    ele
@@ -1215,19 +1215,17 @@
 ubmit();
-%0D%0A%0D
+%0A
 %0A    // 
@@ -1251,17 +1251,16 @@
 the page
-%0D
 %0A    Sys
@@ -1310,27 +1310,25 @@
 getTitle());
-%0D%0A%0D
+%0A
 %0A    // Goog
@@ -1379,17 +1379,16 @@
 aScript.
-%0D
 %0A    // 
@@ -1438,17 +1438,16 @@
  seconds
-%0D
 %0A    (ne
@@ -1515,17 +1515,16 @@
 ean%3E() %7B
-%0D
 %0A      p
@@ -1557,17 +1557,16 @@
 ver d) %7B
-%0D
 %0A       
@@ -1612,17 +1612,17 @@
 tsWith(%22
-C
+c
 heese!%22)
@@ -1626,17 +1626,16 @@
 !%22);
-%0D
 %0A      %7D
 %0D%0A  
@@ -1634,17 +1634,16 @@
    %7D
-%0D
 %0A    %7D);
 %0D%0A%0D%0A
@@ -1638,19 +1638,17 @@
 %0A    %7D);
-%0D%0A%0D
+%0A
 %0A    // 
@@ -1684,17 +1684,16 @@
  Search%22
-%0D
 %0A    Sys
@@ -1751,11 +1751,9 @@
 ());
-%0D%0A%0D
+%0A
 %0A   
@@ -1772,17 +1772,16 @@
  browser
-%0D
 %0A    dri
@@ -1795,12 +1795,10 @@
 t();
-%0D
 %0A  %7D
-%0D
 %0A%7D

Fix google cheese test