-
Notifications
You must be signed in to change notification settings - Fork 188
/
CreateUserTest.java
66 lines (51 loc) · 3.15 KB
/
CreateUserTest.java
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
package com.evolveum.midpoint.testing.selenium.tests.user;
import com.evolveum.midpoint.testing.selenium.tests.BaseTest;
import com.evolveum.midpoint.testing.selenium.tests.LoginTest;
import com.evolveum.midpoint.util.logging.Trace;
import com.evolveum.midpoint.util.logging.TraceManager;
import org.openqa.selenium.By;
import org.testng.Assert;
import org.testng.annotations.Test;
/**
* Created by honchar
*/
public class CreateUserTest extends BaseTest {
private static final Trace LOGGER = TraceManager.getTrace(LoginTest.class);
/**
* Creating new user in the midPoint administrator module
*/
@Test
public void addNewUserTest(){
//log in to system asadministrator
performLogin(driver, userLogin, userPassword);
//click Users menu item in the top vertical menu
driver.findElement(By.cssSelector("html.no-js body div.navbar.navbar-default.navbar-fixed-top div div.navbar-collapse.collapse ul.nav.navbar-nav li.dropdown a.dropdown-toggle")).click();
//click New user menu item
driver.findElement(By.xpath("//li[2]/a/span")).click();
//Clear and fill in the Name mandatory field
driver.findElement(By.name("userForm:body:containers:0:container:properties:0:property:values:0:value:valueContainer:input:input")).clear();
driver.findElement(By.name("userForm:body:containers:0:container:properties:0:property:values:0:value:valueContainer:input:input")).sendKeys("TestUserName");
//Click on Save button
driver.findElement(By.xpath("/html/body/div[4]/div/form/div[5]/a[2]")).click();
//Check is the message appears
Assert.assertEquals("Success", driver.findElement(By.xpath("/html/body/div[4]/div/div[2]/div[1]/ul/li/div/div[1]/div[1]/span")).getText());
Assert.assertEquals("Save user (Gui)", driver.findElement(By.xpath("/html/body/div[4]/div/div[2]/div[1]/ul/li/div/div[1]/div[2]/ul/li/div/span")).getText());
}
/**
* Attemp to create user without mandatory field Name
*/
@Test
public void createUserWithoutNameTest() {
//click Users menu item in the top vertical menu
driver.findElement(By.cssSelector("html.no-js body div.navbar.navbar-default.navbar-fixed-top div div.navbar-collapse.collapse ul.nav.navbar-nav li.dropdown a.dropdown-toggle")).click();
//click New user menu item
driver.findElement(By.xpath("//li[2]/a/span")).click();
//Clear Name mandatory field
driver.findElement(By.name("userForm:body:containers:0:container:properties:0:property:values:0:value:valueContainer:input:input")).clear();
//Click on Save button
driver.findElement(By.xpath("/html/body/div[4]/div/form/div[5]/a[2]")).click();
String errorMessage = "No name in new object null as produced by template null in iteration 0, we cannot process an object without a name: No name in new object null as produced by template null in iteration 0, we cannot process an object without a name";
String messageXpath = "/html/body/div[4]/div/div[2]/div[1]/ul/li/div/div[1]/div[1]/span";
Assert.assertEquals(errorMessage, driver.findElement(By.xpath(messageXpath)).getText());
}
}