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; |
21 |
|
|
22 |
|
import java.util.List; |
23 |
|
|
24 |
|
import org.openqa.selenium.By; |
25 |
|
import org.openqa.selenium.NoSuchElementException; |
26 |
|
import org.openqa.selenium.WebElement; |
27 |
|
import org.openqa.selenium.support.FindBy; |
28 |
|
|
29 |
|
|
30 |
|
|
31 |
|
|
32 |
|
@version |
33 |
|
@since |
34 |
|
|
|
|
| 95.3% |
Uncovered Elements: 2 (43) |
Complexity: 13 |
Complexity Density: 0.41 |
|
35 |
|
public class HistoryPane extends BaseElement |
36 |
|
{ |
37 |
|
@FindBy(id = "historycontent") |
38 |
|
private WebElement pane; |
39 |
|
|
|
|
| 85.7% |
Uncovered Elements: 2 (14) |
Complexity: 4 |
Complexity Density: 0.33 |
|
40 |
1 |
public boolean hasVersionWithSummary(String summary)... |
41 |
|
{ |
42 |
1 |
List<WebElement> tableEntries = pane.findElements(By.xpath(".//table/tbody/tr")); |
43 |
1 |
By commentVersionXPath; |
44 |
1 |
try { |
45 |
1 |
pane.findElement(By.xpath(".//tr[2]/td/input")); |
46 |
1 |
commentVersionXPath = By.xpath(".//td[6]"); |
47 |
|
} catch (NoSuchElementException e) { |
48 |
0 |
commentVersionXPath = By.xpath(".//td[4]"); |
49 |
|
} |
50 |
1 |
for (WebElement tableEntry : tableEntries) { |
51 |
2 |
try { |
52 |
2 |
WebElement cell = tableEntry.findElement(commentVersionXPath); |
53 |
2 |
if (cell.getText().trim().contentEquals(summary)) { |
54 |
1 |
return true; |
55 |
|
} |
56 |
|
} catch (NoSuchElementException e) { |
57 |
|
|
58 |
|
} |
59 |
|
} |
60 |
0 |
return false; |
61 |
|
} |
62 |
|
|
|
|
| 100% |
Uncovered Elements: 0 (1) |
Complexity: 1 |
Complexity Density: 1 |
|
63 |
7 |
public String getCurrentVersion()... |
64 |
|
{ |
65 |
7 |
return getCurrentItemInTable("td[3]/a", "td[1]/a"); |
66 |
|
} |
67 |
|
|
|
|
| 100% |
Uncovered Elements: 0 (1) |
Complexity: 1 |
Complexity Density: 1 |
|
68 |
3 |
public String getCurrentVersionComment()... |
69 |
|
{ |
70 |
3 |
return getCurrentItemInTable("td[6]", "td[4]"); |
71 |
|
} |
72 |
|
|
|
|
| 100% |
Uncovered Elements: 0 (1) |
Complexity: 1 |
Complexity Density: 1 |
|
73 |
4 |
public String getCurrentAuthor()... |
74 |
|
{ |
75 |
4 |
return getCurrentItemInTable("td[4]", "td[2]"); |
76 |
|
} |
77 |
|
|
|
|
| 100% |
Uncovered Elements: 0 (4) |
Complexity: 2 |
Complexity Density: 0.5 |
|
78 |
14 |
private String getCurrentItemInTable(String xpathFragment1, String xpathFragment2)... |
79 |
|
{ |
80 |
14 |
try { |
81 |
|
|
82 |
|
|
83 |
14 |
getDriver().findElementWithoutWaiting(this.pane, By.xpath(".//tr[2]/td/input")); |
84 |
8 |
return getDriver().findElementWithoutWaiting(this.pane, |
85 |
|
By.xpath(".//*[contains(@class, 'currentversion')]/" + xpathFragment1)).getText(); |
86 |
|
} catch (NoSuchElementException e) { |
87 |
|
|
88 |
|
|
89 |
6 |
return getDriver().findElementWithoutWaiting(this.pane, |
90 |
|
By.xpath(".//*[contains(@class, 'currentversion')]/" + xpathFragment2)).getText(); |
91 |
|
} |
92 |
|
} |
93 |
|
|
94 |
|
|
95 |
|
|
96 |
|
|
97 |
|
|
|
|
| 100% |
Uncovered Elements: 0 (3) |
Complexity: 1 |
Complexity Density: 0.33 |
|
98 |
1 |
public ViewPage rollbackToVersion(String version)... |
99 |
|
{ |
100 |
1 |
getDriver().makeConfirmDialogSilent(true); |
101 |
|
|
102 |
1 |
pane.findElement( |
103 |
|
By.xpath(".//table//tr[contains(., '" + version |
104 |
|
+ "')]//td[@class='xwikibuttonlink']/a[contains(.,'Rollback')]")).click(); |
105 |
|
|
106 |
|
|
107 |
|
|
108 |
|
|
109 |
|
|
110 |
|
|
111 |
1 |
return new ViewPage(); |
112 |
|
} |
113 |
|
|
|
|
| 100% |
Uncovered Elements: 0 (3) |
Complexity: 1 |
Complexity Density: 0.33 |
|
114 |
1 |
public HistoryPane deleteVersion(String version)... |
115 |
|
{ |
116 |
1 |
getDriver().makeConfirmDialogSilent(true); |
117 |
|
|
118 |
1 |
pane.findElement( |
119 |
|
By.xpath(".//table//tr[contains(., '" + version |
120 |
|
+ "')]//td[@class='xwikibuttonlink']/a[contains(.,'Delete')]")).click(); |
121 |
|
|
122 |
1 |
return new HistoryPane(); |
123 |
|
} |
124 |
|
|
125 |
|
|
126 |
|
|
127 |
|
|
128 |
|
@return |
129 |
|
|
|
|
| 100% |
Uncovered Elements: 0 (2) |
Complexity: 1 |
Complexity Density: 0.5 |
|
130 |
2 |
public HistoryPane showMinorEdits()... |
131 |
|
{ |
132 |
2 |
getDriver().findElementWithoutWaiting(pane, By.name("viewminorversions")).click(); |
133 |
2 |
return new HistoryPane(); |
134 |
|
} |
135 |
|
|
136 |
|
|
137 |
|
|
138 |
|
|
139 |
|
@param |
140 |
|
@param |
141 |
|
@return |
142 |
|
|
|
|
| 100% |
Uncovered Elements: 0 (5) |
Complexity: 1 |
Complexity Density: 0.2 |
|
143 |
2 |
public ComparePage compare(String fromVersion, String toVersion)... |
144 |
|
{ |
145 |
2 |
String versionXPath = ".//input[@name = 'rev%s' and @value = '%s']"; |
146 |
2 |
getDriver().findElementWithoutWaiting(pane, By.xpath(String.format(versionXPath, 1, fromVersion))).click(); |
147 |
2 |
getDriver().findElementWithoutWaiting(pane, By.xpath(String.format(versionXPath, 2, toVersion))).click(); |
148 |
2 |
getDriver().findElementWithoutWaiting(pane, By.xpath(".//input[@accesskey = 'c']")).click(); |
149 |
2 |
return new ComparePage(); |
150 |
|
} |
151 |
|
} |