| 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 |
|
import java.util.regex.Pattern; |
| 24 |
|
|
| 25 |
|
import org.openqa.selenium.By; |
| 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.xwiki.model.reference.DocumentReference; |
| 31 |
|
import org.xwiki.model.reference.EntityReference; |
| 32 |
|
import org.xwiki.test.ui.po.editor.WYSIWYGEditPage; |
| 33 |
|
|
| 34 |
|
|
| 35 |
|
|
| 36 |
|
|
| 37 |
|
@version |
| 38 |
|
@since |
| 39 |
|
|
| |
|
| 85% |
Uncovered Elements: 9 (60) |
Complexity: 21 |
Complexity Density: 0.57 |
|
| 40 |
|
public class ViewPage extends BasePage |
| 41 |
|
{ |
| 42 |
|
@FindBy(id = "xwikicontent") |
| 43 |
|
private WebElement content; |
| 44 |
|
|
| 45 |
|
@FindBy(id = "hierarchy") |
| 46 |
|
private WebElement breadcrumbElement; |
| 47 |
|
|
| 48 |
|
private BreadcrumbElement breadcrumb; |
| 49 |
|
|
| 50 |
|
|
| 51 |
|
|
| 52 |
|
|
| 53 |
|
@return |
| 54 |
|
|
| |
|
| 100% |
Uncovered Elements: 0 (3) |
Complexity: 1 |
Complexity Density: 0.33 |
|
| 55 |
15 |
public CommentsTab openCommentsDocExtraPane()... |
| 56 |
|
{ |
| 57 |
15 |
getDriver().findElement(By.id("Commentslink")).click(); |
| 58 |
15 |
waitForDocExtraPaneActive("comments"); |
| 59 |
15 |
return new CommentsTab(); |
| 60 |
|
} |
| 61 |
|
|
| |
|
| 100% |
Uncovered Elements: 0 (3) |
Complexity: 1 |
Complexity Density: 0.33 |
|
| 62 |
11 |
public HistoryPane openHistoryDocExtraPane()... |
| 63 |
|
{ |
| 64 |
11 |
getDriver().findElement(By.id("Historylink")).click(); |
| 65 |
11 |
waitForDocExtraPaneActive("history"); |
| 66 |
11 |
return new HistoryPane(); |
| 67 |
|
} |
| 68 |
|
|
| |
|
| 100% |
Uncovered Elements: 0 (3) |
Complexity: 1 |
Complexity Density: 0.33 |
|
| 69 |
6 |
public AttachmentsPane openAttachmentsDocExtraPane()... |
| 70 |
|
{ |
| 71 |
6 |
getDriver().findElement(By.id("Attachmentslink")).click(); |
| 72 |
6 |
waitForDocExtraPaneActive("attachments"); |
| 73 |
6 |
return new AttachmentsPane(); |
| 74 |
|
} |
| 75 |
|
|
| 76 |
|
@return |
| |
|
| 85.7% |
Uncovered Elements: 1 (7) |
Complexity: 3 |
Complexity Density: 0.6 |
|
| 77 |
20 |
public boolean exists()... |
| 78 |
|
{ |
| 79 |
20 |
List<WebElement> messages = getDriver().findElementsWithoutWaiting(By.className("xwikimessage")); |
| 80 |
20 |
for (WebElement message : messages) { |
| 81 |
14 |
if (message.getText().contains("The requested page could not be found.") |
| 82 |
|
|| message.getText().contains("The page has been deleted.")) { |
| 83 |
14 |
return false; |
| 84 |
|
} |
| 85 |
|
} |
| 86 |
6 |
return true; |
| 87 |
|
} |
| 88 |
|
|
| 89 |
|
|
| 90 |
|
@return |
| 91 |
|
|
| |
|
| 100% |
Uncovered Elements: 0 (1) |
Complexity: 1 |
Complexity Density: 1 |
|
| 92 |
91 |
public String getContent()... |
| 93 |
|
{ |
| 94 |
91 |
return this.content.getText(); |
| 95 |
|
} |
| 96 |
|
|
| |
|
| 100% |
Uncovered Elements: 0 (4) |
Complexity: 1 |
Complexity Density: 0.25 |
|
| 97 |
7 |
public WYSIWYGEditPage editSection(int sectionNumber)... |
| 98 |
|
{ |
| 99 |
7 |
By sectionBy = By.xpath("//span[contains(@class, 'edit_section')][" + sectionNumber + "]/a"); |
| 100 |
|
|
| 101 |
|
|
| 102 |
|
|
| 103 |
7 |
getDriver().waitUntilElementIsVisible(sectionBy); |
| 104 |
|
|
| 105 |
7 |
getDriver().findElement(sectionBy).click(); |
| 106 |
7 |
return new WYSIWYGEditPage(); |
| 107 |
|
} |
| 108 |
|
|
| 109 |
|
|
| 110 |
|
|
| 111 |
|
|
| |
|
| 0% |
Uncovered Elements: 1 (1) |
Complexity: 1 |
Complexity Density: 1 |
|
| 112 |
0 |
public void clickWantedLink(String spaceName, String pageName, boolean waitForTemplateDisplay)... |
| 113 |
|
{ |
| 114 |
0 |
clickWantedLink(new DocumentReference("xwiki", spaceName, pageName), waitForTemplateDisplay); |
| 115 |
|
} |
| 116 |
|
|
| 117 |
|
|
| 118 |
|
|
| 119 |
|
|
| 120 |
|
@since |
| 121 |
|
|
| |
|
| 83.3% |
Uncovered Elements: 1 (6) |
Complexity: 2 |
Complexity Density: 0.5 |
|
| 122 |
1 |
public void clickWantedLink(EntityReference reference, boolean waitForTemplateDisplay)... |
| 123 |
|
{ |
| 124 |
1 |
WebElement brokenLink = getDriver().findElement( |
| 125 |
|
By.xpath("//span[@class='wikicreatelink']/a[contains(@href,'/create/" + getUtil().getURLFragment(reference) |
| 126 |
|
+ "')]")); |
| 127 |
1 |
brokenLink.click(); |
| 128 |
1 |
if (waitForTemplateDisplay) { |
| 129 |
|
|
| 130 |
|
|
| 131 |
|
|
| 132 |
1 |
getDriver().waitUntilElementIsVisible(By.xpath("//div[@class='modal-popup']//input[@type='submit']")); |
| 133 |
|
} |
| 134 |
|
} |
| 135 |
|
|
| |
|
| 100% |
Uncovered Elements: 0 (5) |
Complexity: 2 |
Complexity Density: 0.67 |
|
| 136 |
44 |
public BreadcrumbElement getBreadcrumb()... |
| 137 |
|
{ |
| 138 |
44 |
if (this.breadcrumb == null) { |
| 139 |
40 |
this.breadcrumb = new BreadcrumbElement(this.breadcrumbElement); |
| 140 |
|
} |
| 141 |
44 |
return this.breadcrumb; |
| 142 |
|
} |
| 143 |
|
|
| |
|
| 100% |
Uncovered Elements: 0 (1) |
Complexity: 1 |
Complexity Density: 1 |
|
| 144 |
6 |
public String getBreadcrumbContent()... |
| 145 |
|
{ |
| 146 |
6 |
return getBreadcrumb().getPathAsString(); |
| 147 |
|
} |
| 148 |
|
|
| |
|
| 100% |
Uncovered Elements: 0 (1) |
Complexity: 1 |
Complexity Density: 1 |
|
| 149 |
7 |
public boolean hasBreadcrumbContent(String breadcrumbItem, boolean isCurrent)... |
| 150 |
|
{ |
| 151 |
7 |
return hasBreadcrumbContent(breadcrumbItem, isCurrent, true); |
| 152 |
|
} |
| 153 |
|
|
| |
|
| 100% |
Uncovered Elements: 0 (1) |
Complexity: 1 |
Complexity Density: 1 |
|
| 154 |
10 |
public boolean hasBreadcrumbContent(String breadcrumbItem, boolean isCurrent, boolean withLink)... |
| 155 |
|
{ |
| 156 |
10 |
return getBreadcrumb().hasPathElement(breadcrumbItem, isCurrent, withLink); |
| 157 |
|
} |
| 158 |
|
|
| 159 |
|
|
| 160 |
|
|
| 161 |
|
|
| 162 |
|
@param |
| 163 |
|
@return |
| 164 |
|
|
| |
|
| 100% |
Uncovered Elements: 0 (2) |
Complexity: 1 |
Complexity Density: 0.5 |
|
| 165 |
12 |
public ViewPage clickBreadcrumbLink(String linkText)... |
| 166 |
|
{ |
| 167 |
12 |
getBreadcrumb().clickPathElement(linkText); |
| 168 |
|
|
| 169 |
12 |
return new ViewPage(); |
| 170 |
|
} |
| 171 |
|
|
| |
|
| 100% |
Uncovered Elements: 0 (1) |
Complexity: 1 |
Complexity Density: 1 |
|
| 172 |
1 |
public boolean isInlinePage()... |
| 173 |
|
{ |
| 174 |
1 |
return getDriver().findElements(By.xpath("//form[@id = 'inline']")).size() > 0; |
| 175 |
|
} |
| 176 |
|
|
| 177 |
|
|
| 178 |
|
@param |
| 179 |
|
|
| |
|
| 100% |
Uncovered Elements: 0 (1) |
Complexity: 1 |
Complexity Density: 1 |
|
| 180 |
42 |
public void waitForDocExtraPaneActive(String paneId)... |
| 181 |
|
{ |
| 182 |
42 |
getDriver().waitUntilElementIsVisible(By.id(paneId + "content")); |
| 183 |
|
} |
| 184 |
|
|
| 185 |
|
|
| 186 |
|
|
| 187 |
|
|
| 188 |
|
@param |
| 189 |
|
@since |
| 190 |
|
|
| |
|
| 0% |
Uncovered Elements: 1 (1) |
Complexity: 1 |
Complexity Density: 1 |
|
| 191 |
0 |
public void waitUntilContent(final String expectedValue)... |
| 192 |
|
{ |
| 193 |
0 |
getDriver().waitUntilCondition(new ExpectedCondition<Boolean>() |
| 194 |
|
{ |
| 195 |
|
private Pattern pattern = Pattern.compile(expectedValue, Pattern.DOTALL); |
| 196 |
|
|
| |
|
| 0% |
Uncovered Elements: 2 (2) |
Complexity: 1 |
Complexity Density: 0.5 |
|
| 197 |
0 |
@Override... |
| 198 |
|
public Boolean apply(WebDriver driver) |
| 199 |
|
{ |
| 200 |
0 |
driver.navigate().refresh(); |
| 201 |
0 |
return Boolean.valueOf(pattern.matcher(getContent()).matches()); |
| 202 |
|
} |
| 203 |
|
}); |
| 204 |
|
} |
| 205 |
|
} |