Advertisement
smaction

ldltable

Aug 31st, 2011
186
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Java 2.27 KB | None | 0 0
  1. package test;
  2.  
  3.  
  4. import java.util.regex.Pattern;
  5. import java.util.concurrent.TimeUnit;
  6. import org.junit.*;
  7. import static org.junit.Assert.*;
  8. import static org.hamcrest.CoreMatchers.*;
  9. import org.openqa.selenium.*;
  10. import org.openqa.selenium.firefox.FirefoxDriver;
  11. import org.openqa.selenium.ie.InternetExplorerDriver;
  12. import org.openqa.selenium.support.ui.Select;
  13.  
  14. public class tableldl {
  15.     private WebDriver driver;
  16.     private String baseUrl="";
  17.     private StringBuffer verificationErrors = new StringBuffer();
  18.     @Before
  19.     public void setUp() throws Exception {
  20.         driver = new FirefoxDriver();
  21.        
  22.      //driver.manage().timeouts().implicitlyWait(30, TimeUnit.SECONDS);
  23.     // driver.manage().setSpeed(Speed.slow);
  24.     }
  25.  
  26.     @Test
  27.     public void testTableldl() throws Exception {
  28.         // ERROR: Caught exception [ERROR: Unsupported command [setSpeed]]
  29.         driver.get("http://www.ldlcasino.com");
  30.         Thread.sleep(30000);
  31.         if (isElementPresent(By.id("close_welcome_box")))driver.findElement(By.id("close_welcome_box")).click();
  32.         driver.findElement(By.id("dashTabOverlay")).click();
  33.        
  34.         Thread.sleep(30000);
  35.        
  36.         driver.findElement(By.id("obTable")).click();
  37.    
  38.         for (int second = 0;; second++) {
  39.             if (second >= 60) fail("timeout");
  40.             try { if (isElementPresent(By.id("time"))) break; } catch (Exception e) {}
  41.             Thread.sleep(1000);
  42.         }
  43.        
  44.        
  45.         Select select= new Select(driver.findElement(By.id("time")));
  46.         select.selectByVisibleText("11:00PM");
  47.         for (int second = 0;; second++) {
  48.             if (second >= 60) fail("timeout");
  49.             try { if (isElementPresent(By.id("checkAvailability"))) break; } catch (Exception e) {}
  50.             Thread.sleep(1000);
  51.         }
  52.        
  53.         driver.findElement(By.id("checkAvailability")).click();
  54.         for (int second = 0;; second++) {
  55.             if (second >= 60) fail("timeout");
  56.             try { if (isElementPresent(By.id("booking_0"))) break; } catch (Exception e) {}
  57.             Thread.sleep(1000);
  58.         }
  59.  
  60.     }
  61.  
  62.     @After
  63.     public void tearDown() throws Exception {
  64.         driver.quit();
  65.         String verificationErrorString = verificationErrors.toString();
  66.         if (!"".equals(verificationErrorString)) {
  67.             fail(verificationErrorString);
  68.         }
  69.     }
  70.  
  71.     private boolean isElementPresent(By by) {
  72.         try {
  73.             driver.findElement(by);
  74.             return true;
  75.         } catch (NoSuchElementException e) {
  76.             return false;
  77.         }
  78.     }
  79. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement