-
Notifications
You must be signed in to change notification settings - Fork 188
/
InlineMenu.java
93 lines (73 loc) · 2.6 KB
/
InlineMenu.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
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
/*
* Copyright (c) 2010-2020 Evolveum
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package com.evolveum.midpoint.schrodinger.component.common;
import java.util.ArrayList;
import java.util.List;
import com.codeborne.selenide.ElementsCollection;
import com.codeborne.selenide.SelenideElement;
import com.evolveum.midpoint.schrodinger.component.Component;
/**
* Created by Viliam Repan (lazyman).
*/
public class InlineMenu<T> extends Component<T> {
public InlineMenu(T parent, SelenideElement parentElement) {
super(parent, parentElement);
}
public InlineMenu<T> caret() {
SelenideElement caret = getParentElement().find("div.btn-group span[data-s-id=caret]");
if (caret != null) {
caret.click();
}
return this;
}
public List<String> getItems() {
List<String> items = new ArrayList<>();
ElementsCollection lis = getParentElement().findAll("div.btn-group ul.dropdown-menu li a");
for (SelenideElement a : lis) {
if (!a.isDisplayed()) {
continue;
}
String txt = a.getText();
if (txt != null) {
items.add(txt.trim());
}
}
return items;
}
public List<String> getItemKeys() {
List<String> items = new ArrayList<>();
ElementsCollection lis = getParentElement().findAll("div.btn-group ul.dropdown-menu li a schrodinger[data-s-resource-key]");
for (SelenideElement schrodinger : lis) {
if (!schrodinger.parent().isDisplayed()) {
continue;
}
String key = schrodinger.getAttribute("data-s-resource-key");
if (key != null) {
items.add(key.trim());
}
}
return items;
}
public InlineMenu<T> clickItemByName(String itemName) {
// todo implement
SelenideElement dropdown = getParentElement().find("div.btn-group ul.dropdown-menu li");
return this;
}
public InlineMenu<T> clickItemByKey(String itemKey) {
// todo implement
return this;
}
}