-
Notifications
You must be signed in to change notification settings - Fork 188
/
Util.java
68 lines (54 loc) · 2.4 KB
/
Util.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
66
67
68
package com.evolveum.midpoint.testing.selenide.tests;
import com.codeborne.selenide.SelenideElement;
import org.openqa.selenium.By;
import org.springframework.stereotype.Component;
import org.testng.annotations.Test;
import java.io.File;
import static com.codeborne.selenide.Condition.text;
import static com.codeborne.selenide.Condition.visible;
import static com.codeborne.selenide.Selenide.$;
import static com.codeborne.selenide.Selenide.close;
import static com.codeborne.selenide.Selenide.open;
/**
* Created by Kate on 13.08.2015.
*/
@Component
public class Util {
public static final String SITE_URL = "/midpoint";
public static final String ADMIN_LOGIN = "administrator";
public static final String ADMIN_PASSWORD = "5ecr3t";
/**
* Looks for the element with specified searchText
* and returns the first element from the search results
* @param searchText
* @return
*/
public void searchForElement(String searchText, String searchButtonXpath){
//search for element in search form
$(By.name("basicSearch:searchText")).shouldBe(visible).setValue(searchText);
$(By.xpath(searchButtonXpath)).shouldHave(text("Search")).click();
}
public void importObjectFromFile(String filePath){
//click Configuration menu
$(By.xpath("/html/body/div[3]/div/div[2]/ul[1]/li[8]/a"))
.shouldHave(text("Configuration")).click();
//click Import object menu item
$(By.linkText("Import object")).click();
//select Overwrite existing object check box
$(By.name("importOptions:overwriteExistingObject")).setSelected(true);
//Specify the file to be uploaded
File test = new File(filePath);
$(By.name("input:inputFile:fileInput")).uploadFile(test);
//click Import object button
$(By.xpath("/html/body/div[4]/div/form/div[6]/a")).shouldHave(text("Import object")).click();
//check if Success message appears after resource importing
$(By.xpath("/html/body/div[4]/div/div[2]/div[1]/ul/li/div/div[1]/div[1]/span")).shouldHave(text("Success"));
}
public void logout(){
//click administrator menu in the upper right corner of the window
$(By.xpath("/html/body/div[3]/div/div[2]/ul[2]/li/a"))
.shouldBe(visible).click();
//click on Log out menu item
$(By.linkText("Log out")).shouldBe(visible).click();
}
}