aslak

Arquillian - Selenium - Spock - Form

Sep 2nd, 2010
128
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Groovy 1.10 KB | None | 0 0
  1. class LoginFormValidation extends Specification {
  2.  
  3.     @Deployment
  4.     def static JavaArchive "create deployment"() {
  5.         return ShrinkWrap.create(WebArchive.class)......;
  6.     }
  7.  
  8.     By LOGGED_IN = By.xpath("//li[contains(text(),'Welcome')]");
  9.     By LOGGED_OUT = By.xpath("//li[contains(text(),'Goodbye')]");
  10.  
  11.     By USERNAME_FIELD = By.id("loginForm:username");
  12.     By PASSWORD_FIELD = By.id("loginForm:password");
  13.  
  14.     By LOGIN_BUTTON = By.id("loginForm:login");
  15.     By LOGOUT_BUTTON = By.id("loginForm:logout");
  16.    
  17.     @Selenium
  18.     WebDriver driver;
  19.        
  20.     def "should be possible to login"() {
  21.         when:
  22.         driver.get("http://localhost:8080/weld-login/home.jsf");
  23.  
  24.         driver.findElement(USERNAME_FIELD).sendKeys(username);
  25.         driver.findElement(PASSWORD_FIELD).sendKeys(password);
  26.         driver.findElement(LOGIN_BUTTON).submit();
  27.        
  28.         then:
  29.         checkElementPresence(LOGGED_IN, "User should be logged in!");
  30.        
  31.         where:
  32.         username <<         ["aslak",   "dan"]
  33.         password <<         ["xxx",     "xxx"]
  34.     }
  35. }
Add Comment
Please, Sign In to add comment