1 |
|
|
2 |
|
|
3 |
|
|
4 |
|
|
5 |
|
|
6 |
|
|
7 |
|
|
8 |
|
|
9 |
|
|
10 |
|
|
11 |
|
|
12 |
|
|
13 |
|
|
14 |
|
|
15 |
|
|
16 |
|
|
17 |
|
|
18 |
|
|
19 |
|
|
20 |
|
package org.xwiki.test.ui.po.editor; |
21 |
|
|
22 |
|
import java.util.List; |
23 |
|
|
24 |
|
import org.openqa.selenium.By; |
25 |
|
import org.openqa.selenium.NotFoundException; |
26 |
|
import org.openqa.selenium.WebDriver; |
27 |
|
import org.openqa.selenium.WebElement; |
28 |
|
import org.openqa.selenium.support.FindBy; |
29 |
|
import org.openqa.selenium.support.ui.ExpectedCondition; |
30 |
|
import org.openqa.selenium.support.ui.Select; |
31 |
|
import org.xwiki.test.ui.po.BaseElement; |
32 |
|
|
33 |
|
|
34 |
|
|
35 |
|
|
36 |
|
@version |
37 |
|
@since |
38 |
|
|
|
|
| 83% |
Uncovered Elements: 9 (53) |
Complexity: 18 |
Complexity Density: 0.55 |
|
39 |
|
public class DatePicker extends BaseElement |
40 |
|
{ |
41 |
|
|
42 |
|
|
43 |
|
|
44 |
|
@FindBy(className = "calendar_date_select") |
45 |
|
private WebElement container; |
46 |
|
|
|
|
| 100% |
Uncovered Elements: 0 (1) |
Complexity: 1 |
Complexity Density: 1 |
|
47 |
6 |
public DatePicker()... |
48 |
|
{ |
49 |
6 |
this.waitToLoad(); |
50 |
|
} |
51 |
|
|
52 |
|
|
53 |
|
|
54 |
|
|
55 |
|
@param |
56 |
|
|
|
|
| 100% |
Uncovered Elements: 0 (2) |
Complexity: 1 |
Complexity Density: 0.5 |
|
57 |
1 |
public void setYear(String year)... |
58 |
|
{ |
59 |
1 |
Select yearSelector = new Select(container.findElement(By.className("year"))); |
60 |
1 |
yearSelector.selectByVisibleText(year); |
61 |
|
} |
62 |
|
|
63 |
|
|
64 |
|
@return |
65 |
|
|
|
|
| 100% |
Uncovered Elements: 0 (2) |
Complexity: 1 |
Complexity Density: 0.5 |
|
66 |
2 |
public String getYear()... |
67 |
|
{ |
68 |
2 |
Select yearSelector = new Select(container.findElement(By.className("year"))); |
69 |
2 |
return yearSelector.getFirstSelectedOption().getText(); |
70 |
|
} |
71 |
|
|
72 |
|
|
73 |
|
|
74 |
|
|
75 |
|
@param |
76 |
|
|
|
|
| 100% |
Uncovered Elements: 0 (2) |
Complexity: 1 |
Complexity Density: 0.5 |
|
77 |
1 |
public void setMonth(String month)... |
78 |
|
{ |
79 |
1 |
Select monthSelector = new Select(container.findElement(By.className("month"))); |
80 |
1 |
monthSelector.selectByVisibleText(month); |
81 |
|
} |
82 |
|
|
83 |
|
|
84 |
|
@return |
85 |
|
|
|
|
| 100% |
Uncovered Elements: 0 (2) |
Complexity: 1 |
Complexity Density: 0.5 |
|
86 |
2 |
public String getMonth()... |
87 |
|
{ |
88 |
2 |
Select monthSelector = new Select(container.findElement(By.className("month"))); |
89 |
2 |
return monthSelector.getFirstSelectedOption().getText(); |
90 |
|
} |
91 |
|
|
92 |
|
|
93 |
|
|
94 |
|
|
95 |
|
@param |
96 |
|
|
|
|
| 100% |
Uncovered Elements: 0 (1) |
Complexity: 1 |
Complexity Density: 1 |
|
97 |
3 |
public void setDay(String day)... |
98 |
|
{ |
99 |
3 |
container.findElement(By.xpath("//*[@class = 'cds_body']//tbody//div[. = '" + day + "' and not(@class)]")) |
100 |
|
.click(); |
101 |
|
} |
102 |
|
|
103 |
|
|
104 |
|
@return |
105 |
|
|
|
|
| 71.4% |
Uncovered Elements: 2 (7) |
Complexity: 2 |
Complexity Density: 0.4 |
|
106 |
3 |
public String getDay()... |
107 |
|
{ |
108 |
3 |
String xpath = "//*[@class = 'cds_body']//tbody//*[contains(@class, 'selected')]"; |
109 |
3 |
List<WebElement> selected = container.findElements(By.xpath(xpath)); |
110 |
3 |
if (selected.size() == 1) { |
111 |
3 |
return selected.get(0).getText(); |
112 |
|
} |
113 |
0 |
return null; |
114 |
|
} |
115 |
|
|
116 |
|
|
117 |
|
|
118 |
|
|
119 |
|
@param |
120 |
|
|
|
|
| 100% |
Uncovered Elements: 0 (2) |
Complexity: 1 |
Complexity Density: 0.5 |
|
121 |
1 |
public void setHour(String hour)... |
122 |
|
{ |
123 |
1 |
Select hourSelector = new Select(container.findElement(By.className("hour"))); |
124 |
1 |
hourSelector.selectByVisibleText(hour); |
125 |
|
} |
126 |
|
|
127 |
|
|
128 |
|
@return |
129 |
|
|
|
|
| 100% |
Uncovered Elements: 0 (2) |
Complexity: 1 |
Complexity Density: 0.5 |
|
130 |
1 |
public String getHour()... |
131 |
|
{ |
132 |
1 |
Select hourSelector = new Select(container.findElement(By.className("hour"))); |
133 |
1 |
return hourSelector.getFirstSelectedOption().getText(); |
134 |
|
} |
135 |
|
|
136 |
|
|
137 |
|
|
138 |
|
|
139 |
|
@param |
140 |
|
|
|
|
| 40% |
Uncovered Elements: 6 (10) |
Complexity: 3 |
Complexity Density: 0.5 |
|
141 |
1 |
public void setMinute(String minute)... |
142 |
|
{ |
143 |
1 |
Select minuteSelector = new Select(container.findElement(By.className("minute"))); |
144 |
1 |
if (minuteSelector.getFirstSelectedOption().getText().equals(minute)) { |
145 |
|
|
146 |
|
|
147 |
|
|
148 |
|
|
149 |
|
|
150 |
0 |
minuteSelector.selectByIndex(0); |
151 |
0 |
if (minuteSelector.getFirstSelectedOption().getText().equals(minute)) { |
152 |
0 |
minuteSelector.selectByIndex(1); |
153 |
|
} |
154 |
|
} |
155 |
1 |
minuteSelector.selectByVisibleText(minute); |
156 |
|
} |
157 |
|
|
158 |
|
|
159 |
|
@return |
160 |
|
|
|
|
| 100% |
Uncovered Elements: 0 (2) |
Complexity: 1 |
Complexity Density: 0.5 |
|
161 |
1 |
public String getMinute()... |
162 |
|
{ |
163 |
1 |
Select minuteSelector = new Select(container.findElement(By.className("minute"))); |
164 |
1 |
return minuteSelector.getFirstSelectedOption().getText(); |
165 |
|
} |
166 |
|
|
167 |
|
|
168 |
|
@return |
169 |
|
|
|
|
| 100% |
Uncovered Elements: 0 (1) |
Complexity: 1 |
Complexity Density: 1 |
|
170 |
2 |
public boolean hasHourSelector()... |
171 |
|
{ |
172 |
2 |
return getDriver().findElementsWithoutWaiting(container, By.className("hour")).size() > 0; |
173 |
|
} |
174 |
|
|
175 |
|
|
176 |
|
|
177 |
|
|
178 |
|
@since |
179 |
|
|
|
|
| 100% |
Uncovered Elements: 0 (2) |
Complexity: 1 |
Complexity Density: 0.5 |
|
180 |
6 |
public DatePicker waitToLoad()... |
181 |
|
{ |
182 |
6 |
getDriver().waitUntilCondition(new ExpectedCondition<Boolean>() |
183 |
|
{ |
|
|
| 66.7% |
Uncovered Elements: 1 (3) |
Complexity: 2 |
Complexity Density: 0.67 |
|
184 |
6 |
@Override... |
185 |
|
public Boolean apply(WebDriver driver) |
186 |
|
{ |
187 |
6 |
try { |
188 |
|
|
189 |
|
|
190 |
6 |
return container.isDisplayed(); |
191 |
|
} catch (NotFoundException e) { |
192 |
0 |
return false; |
193 |
|
} |
194 |
|
} |
195 |
|
}); |
196 |
6 |
return this; |
197 |
|
} |
198 |
|
} |