Skip to content

Instantly share code, notes, and snippets.

@framiere
Last active December 24, 2015 09:29
Show Gist options
  • Save framiere/6777267 to your computer and use it in GitHub Desktop.
Save framiere/6777267 to your computer and use it in GitHub Desktop.
@Test
public void casUsageFonctionnel(WebDriver driver) {
String baseUrl = "http://localhost:8080";
driver.get(baseUrl + "/books/");
driver.findElement(By.id("form:selectAccounts")).click();
assertEquals("Identification", driver.getTitle());
driver.findElement(By.id("j_username")).clear();
driver.findElement(By.id("j_username")).sendKeys("admin");
driver.findElement(By.id("login")).click();
assertEquals("Application books", driver.getTitle());
driver.findElement(By.id("form:selectAccounts")).click();
assertEquals("Recherche de Compte Utilisateur", driver.getTitle());
driver.findElement(By.xpath("//div[@id='form:username_panel']/ul/li")).click();
driver.findElement(By.cssSelector("td.isEnabled")).click();
assertEquals("Édition de homer", driver.getTitle());
driver.findElement(By.id("form:username")).clear();
driver.findElement(By.id("form:username")).sendKeys("cnorris");
driver.findElement(By.id("form:password")).clear();
driver.findElement(By.id("form:password")).sendKeys("kickass");
driver.findElement(By.id("form:email")).clear();
driver.findElement(By.id("form:email")).sendKeys("gmail@chucknorris.com");
driver.findElement(By.xpath("(//button[@type='button'])[4]")).click();
driver.findElement(By.xpath("//div[@id='form:homeAddress_panel']/ul/li")).click();
driver.findElement(By.linkText("Droits attribués")).click();
driver.findElement(By.xpath("//a[@id='form:tabs:securityRolesList:selectSecurityRole']/div")).click();
assertEquals("Recherche de Droit", driver.getTitle());
driver.findElement(By.xpath("//div[@id='form:roleName_panel']/ul/li[2]")).click();
driver.findElement(By.xpath("//a[@id='form:searchResults:0:j_idt88']/div")).click();
assertEquals("Édition de cnorris", driver.getTitle());
driver.findElement(By.xpath("//a[@id='form:tabs:securityRolesList:addSecurityRole']/div")).click();
assertEquals("Création de Droit", driver.getTitle());
driver.findElement(By.id("form:roleName")).clear();
driver.findElement(By.id("form:roleName")).sendKeys("ROLE_GOD");
driver.findElement(By.id("form:ok")).click();
assertEquals("Édition de cnorris", driver.getTitle());
driver.findElement(By.linkText("Documents attachés")).click();
driver.findElement(By.xpath("//a[@id='form:tabs:edocsList:addEdoc']/div")).click();
assertEquals("Création de Document", driver.getTitle());
driver.findElement(By.id("form:ok")).click();
assertEquals("Édition de cnorris", driver.getTitle());
driver.findElement(By.id("form:saveAndClose")).click();
assertEquals("Recherche de Compte Utilisateur", driver.getTitle());
driver.findElement(By.id("form:logout_link")).click();
assertEquals("Application books", driver.getTitle());
assertEquals("Identification", driver.getTitle());
driver.findElement(By.id("j_username")).clear();
driver.findElement(By.id("j_username")).sendKeys("cnorris");
driver.findElement(By.id("j_password")).clear();
driver.findElement(By.id("j_password")).sendKeys("kickass");
driver.findElement(By.id("login")).click();
assertEquals("Application books", driver.getTitle());
driver.findElement(By.id("form:logout_link")).click();
assertEquals("Application books", driver.getTitle());
assertEquals("Identification", driver.getTitle());
driver.findElement(By.id("j_username")).clear();
driver.findElement(By.id("j_username")).sendKeys("admin");
driver.findElement(By.id("login")).click();
assertEquals("Application books", driver.getTitle());
driver.findElement(By.id("form:selectAccounts")).click();
assertEquals("Recherche de Compte Utilisateur", driver.getTitle());
driver.findElement(By.cssSelector("li.ui-autocomplete-input-token")).click();
driver.findElement(By.xpath("//div[@id='form:username_panel']/ul/li")).click();
driver.findElement(By.cssSelector("td.isEnabled")).click();
assertEquals("Édition de cnorris", driver.getTitle());
driver.findElement(By.id("form:username")).clear();
driver.findElement(By.id("form:username")).sendKeys("homer");
driver.findElement(By.id("form:password")).clear();
driver.findElement(By.id("form:password")).sendKeys("homer");
driver.findElement(By.id("form:email")).clear();
driver.findElement(By.id("form:email")).sendKeys("homer@simpson.com");
driver.findElement(By.xpath("(//button[@type='button'])[4]")).click();
driver.findElement(By.xpath("//div[@id='form:homeAddress_panel']/ul/li[4]")).click();
driver.findElement(By.linkText("Documents attachés")).click();
driver.findElement(By.xpath("//a[@id='form:tabs:edocsList:0:j_idt134']/div")).click();
driver.findElement(By.id("form:askForRemoveEdocDialogYes")).click();
driver.findElement(By.linkText("Droits attribués")).click();
driver.findElement(By.xpath("//a[@id='form:tabs:securityRolesList:0:j_idt143']/div")).click();
driver.findElement(By.id("form:askForRemoveSecurityRoleDialogYes")).click();
driver.findElement(By.xpath("//a[@id='form:tabs:securityRolesList:0:j_idt143']/div")).click();
driver.findElement(By.id("form:askForRemoveSecurityRoleDialogYes")).click();
driver.findElement(By.id("form:saveAndClose")).click();
assertEquals("Recherche de Compte Utilisateur", driver.getTitle());
driver.findElement(By.id("form:j_idt30_button")).click();
driver.findElement(By.id("form:j_idt36")).click();
assertEquals("Recherche de Droit", driver.getTitle());
driver.findElement(By.xpath("//a[@id='form:searchResults:1:j_idt94']/div")).click();
driver.findElement(By.id("form:askForDeleteItemDialogYes")).click();
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment