1 |
|
|
2 |
|
|
3 |
|
|
4 |
|
|
5 |
|
|
6 |
|
|
7 |
|
|
8 |
|
|
9 |
|
|
10 |
|
|
11 |
|
|
12 |
|
|
13 |
|
|
14 |
|
|
15 |
|
|
16 |
|
|
17 |
|
|
18 |
|
|
19 |
|
|
20 |
|
package org.xwiki.flamingo.test.po; |
21 |
|
|
22 |
|
import java.util.ArrayList; |
23 |
|
import java.util.List; |
24 |
|
|
25 |
|
import org.openqa.selenium.By; |
26 |
|
import org.openqa.selenium.Keys; |
27 |
|
import org.openqa.selenium.WebElement; |
28 |
|
import org.openqa.selenium.support.FindBy; |
29 |
|
import org.xwiki.test.ui.po.editor.EditPage; |
30 |
|
|
|
|
| 97.4% |
Uncovered Elements: 1 (39) |
Complexity: 13 |
Complexity Density: 0.52 |
|
31 |
|
public class EditThemePage extends EditPage |
32 |
|
{ |
33 |
|
@FindBy(id = "autosync") |
34 |
|
private WebElement autoSyncCheckBox; |
35 |
|
|
36 |
|
@FindBy(id = "refresh") |
37 |
|
private WebElement refreshButton; |
38 |
|
|
39 |
|
@FindBy(id = "preview-curtain") |
40 |
|
private WebElement previewCurtain; |
41 |
|
|
|
|
| 100% |
Uncovered Elements: 0 (1) |
Complexity: 1 |
Complexity Density: 1 |
|
42 |
2 |
public EditThemePage()... |
43 |
|
{ |
44 |
2 |
waitUntilPageJSIsLoaded(); |
45 |
|
} |
46 |
|
|
|
|
| 100% |
Uncovered Elements: 0 (3) |
Complexity: 1 |
Complexity Density: 0.33 |
|
47 |
8 |
public void selectVariableCategory(String category)... |
48 |
|
{ |
49 |
8 |
WebElement categoryElem = getDriver().findElement( |
50 |
|
By.xpath("//div[@id='panel-theme-variables']//div[@class='panel-body']" |
51 |
|
+ "//li//a[@data-toggle='tab' and text()='" + category + "']")); |
52 |
8 |
categoryElem.click(); |
53 |
|
|
54 |
8 |
getDriver().waitUntilElementIsVisible( |
55 |
|
By.xpath("//div[@id='bt-variables']//div[contains(@class, 'active')]/h2[text()='"+category+"']")); |
56 |
|
} |
57 |
|
|
|
|
| 100% |
Uncovered Elements: 0 (5) |
Complexity: 1 |
Complexity Density: 0.2 |
|
58 |
3 |
public List<String> getVariableCategories()... |
59 |
|
{ |
60 |
3 |
List<String> results = new ArrayList<>(); |
61 |
3 |
List<WebElement> categoryElems = getDriver().findElements( |
62 |
|
By.xpath("//div[@id='panel-theme-variables']//div[@class='panel-body']" |
63 |
|
+ "//li//a[@data-toggle='tab']")); |
64 |
3 |
for (WebElement elem : categoryElems) { |
65 |
33 |
results.add(elem.getText()); |
66 |
|
} |
67 |
|
|
68 |
3 |
return results; |
69 |
|
} |
70 |
|
|
|
|
| 75% |
Uncovered Elements: 1 (4) |
Complexity: 2 |
Complexity Density: 1 |
|
71 |
2 |
public void setAutoRefresh(boolean enabled)... |
72 |
|
{ |
73 |
2 |
if (autoSyncCheckBox.isEnabled() != enabled) { |
74 |
2 |
autoSyncCheckBox.click(); |
75 |
|
} |
76 |
|
} |
77 |
|
|
|
|
| 100% |
Uncovered Elements: 0 (3) |
Complexity: 1 |
Complexity Density: 0.33 |
|
78 |
4 |
public void setVariableValue(String variableName, String value)... |
79 |
|
{ |
80 |
4 |
WebElement variableField = getDriver().findElement(By.xpath("//label[text() = '@"+variableName+"']/..//input")); |
81 |
|
|
82 |
4 |
variableField.sendKeys(Keys.chord(Keys.CONTROL, "a"), Keys.BACK_SPACE); |
83 |
|
|
84 |
4 |
variableField.sendKeys(value); |
85 |
|
} |
86 |
|
|
87 |
|
|
88 |
|
@since |
89 |
|
|
|
|
| 100% |
Uncovered Elements: 0 (3) |
Complexity: 1 |
Complexity Density: 0.33 |
|
90 |
2 |
public void setTextareaValue(String variableName, String value)... |
91 |
|
{ |
92 |
2 |
WebElement variableField = getDriver().findElement( |
93 |
|
By.xpath("//label[text() = '@"+variableName+"']/..//textarea")); |
94 |
|
|
95 |
2 |
variableField.sendKeys(Keys.chord(Keys.CONTROL, "a"), Keys.BACK_SPACE); |
96 |
|
|
97 |
2 |
variableField.sendKeys(value); |
98 |
|
} |
99 |
|
|
|
|
| 100% |
Uncovered Elements: 0 (1) |
Complexity: 1 |
Complexity Density: 1 |
|
100 |
1 |
public void clickOnRefreshPreview()... |
101 |
|
{ |
102 |
1 |
refreshButton.click(); |
103 |
|
} |
104 |
|
|
|
|
| 100% |
Uncovered Elements: 0 (2) |
Complexity: 1 |
Complexity Density: 0.5 |
|
105 |
1 |
public void refreshPreview()... |
106 |
|
{ |
107 |
1 |
clickOnRefreshPreview(); |
108 |
1 |
waitUntilPreviewIsLoaded(); |
109 |
|
} |
110 |
|
|
|
|
| 100% |
Uncovered Elements: 0 (1) |
Complexity: 1 |
Complexity Density: 1 |
|
111 |
1 |
public boolean isPreviewBoxLoading()... |
112 |
|
{ |
113 |
1 |
return previewCurtain.isDisplayed(); |
114 |
|
} |
115 |
|
|
|
|
| 100% |
Uncovered Elements: 0 (1) |
Complexity: 1 |
Complexity Density: 1 |
|
116 |
3 |
public void waitUntilPreviewIsLoaded()... |
117 |
|
{ |
118 |
3 |
getDriver().waitUntilElementDisappears(By.id("preview-curtain")); |
119 |
|
} |
120 |
|
|
|
|
| 100% |
Uncovered Elements: 0 (1) |
Complexity: 1 |
Complexity Density: 1 |
|
121 |
1 |
public PreviewBox getPreviewBox()... |
122 |
|
{ |
123 |
1 |
return new PreviewBox(); |
124 |
|
} |
125 |
|
|
|
|
| 100% |
Uncovered Elements: 0 (2) |
Complexity: 1 |
Complexity Density: 0.5 |
|
126 |
1 |
@Override... |
127 |
|
public ViewThemePage clickSaveAndView() |
128 |
|
{ |
129 |
1 |
this.save.click(); |
130 |
1 |
return new ViewThemePage(); |
131 |
|
} |
132 |
|
|
133 |
|
} |