SHARE
TWEET

Example - get JavaScript countdown using selenium webdriver

SeleniumETrainR Dec 21st, 2012 26 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. import java.util.concurrent.TimeUnit;
  2.  
  3. import org.openqa.selenium.By;
  4. import org.openqa.selenium.WebDriver;
  5. import org.openqa.selenium.firefox.FirefoxDriver;
  6.  
  7.  
  8. public class ExampleJavaScriptcountdown {
  9. public static String before = null;
  10. public static String after = null;
  11.         public static void main(String[] args) {
  12.                 WebDriver myTestDriver = new FirefoxDriver();
  13.                 myTestDriver.manage().window().maximize();
  14.                
  15.                 myTestDriver.manage().timeouts().implicitlyWait(20,TimeUnit.SECONDS);
  16.                
  17.                 myTestDriver.get("http://tinyurl.com/dxwzzf3");
  18.                
  19.  
  20.                
  21.                 while(true){
  22.                         after=myTestDriver.findElement(By.xpath("//*[@id='javascript_countdown_time']")).getText();
  23.                  
  24.  
  25.                         if(!after.equals(before)){
  26.                                 System.out.println(after);
  27.                                 before=after;
  28.                                
  29.                         }              
  30.                        
  31.                 }
  32.  
  33.         }
  34.  
  35. }
RAW Paste Data
We use cookies for various purposes including analytics. By continuing to use Pastebin, you agree to our use of cookies as described in the Cookies Policy. OK, I Understand
 
Top