| 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 |
|
|
| |
|
| 45.7% |
Uncovered Elements: 25 (46) |
Complexity: 17 |
Complexity Density: 0.59 |
|
| 35 |
|
public class AttachmentsPane extends BaseElement |
| 36 |
|
{ |
| 37 |
|
@FindBy(id = "Attachmentspane") |
| 38 |
|
private WebElement pane; |
| 39 |
|
|
| 40 |
|
@FindBy(xpath = "//input[@value='Add another file']") |
| 41 |
|
private WebElement addAnotherFile; |
| 42 |
|
|
| 43 |
|
|
| 44 |
|
|
| 45 |
|
|
| 46 |
|
@param |
| 47 |
|
|
| |
|
| 100% |
Uncovered Elements: 0 (2) |
Complexity: 1 |
Complexity Density: 0.5 |
|
| 48 |
8 |
public void setFileToUpload(final String filePath)... |
| 49 |
|
{ |
| 50 |
8 |
final List<WebElement> inputs = this.pane.findElements(By.className("uploadFileInput")); |
| 51 |
8 |
inputs.get(inputs.size() - 1).sendKeys(filePath); |
| 52 |
|
} |
| 53 |
|
|
| |
|
| 100% |
Uncovered Elements: 0 (1) |
Complexity: 1 |
Complexity Density: 1 |
|
| 54 |
7 |
public void waitForUploadToFinish(String fileName)... |
| 55 |
|
{ |
| 56 |
7 |
waitForNotificationSuccessMessage("Attachment uploaded: " + fileName); |
| 57 |
|
} |
| 58 |
|
|
| |
|
| 100% |
Uncovered Elements: 0 (1) |
Complexity: 1 |
Complexity Density: 1 |
|
| 59 |
4 |
public void clickHideProgress()... |
| 60 |
|
{ |
| 61 |
4 |
this.pane.findElement(By.xpath("//a[text()='Hide upload status']")).click(); |
| 62 |
|
} |
| 63 |
|
|
| 64 |
|
|
| 65 |
|
|
| 66 |
|
|
| |
|
| 0% |
Uncovered Elements: 1 (1) |
Complexity: 1 |
Complexity Density: 1 |
|
| 67 |
0 |
public void addAnotherFile()... |
| 68 |
|
{ |
| 69 |
0 |
this.addAnotherFile.click(); |
| 70 |
|
} |
| 71 |
|
|
| |
|
| 0% |
Uncovered Elements: 1 (1) |
Complexity: 1 |
Complexity Density: 1 |
|
| 72 |
0 |
public void clickAttachFiles()... |
| 73 |
|
{ |
| 74 |
0 |
this.pane.findElement(By.xpath("//form[@id='AddAttachment']//input[@class='button' and @type='submit' and " |
| 75 |
|
+ "@value='Attach']")).click(); |
| 76 |
|
} |
| 77 |
|
|
| 78 |
|
|
| 79 |
|
@since |
| 80 |
|
|
| |
|
| 100% |
Uncovered Elements: 0 (1) |
Complexity: 1 |
Complexity Density: 1 |
|
| 81 |
2 |
public WebElement getAttachmentLink(String attachmentName)... |
| 82 |
|
{ |
| 83 |
2 |
return getDriver().findElement( |
| 84 |
|
By.xpath("//div[@id='_attachments']//a[@title = 'Download this attachment' and contains(@href, '" |
| 85 |
|
+ attachmentName + "')]")); |
| 86 |
|
} |
| 87 |
|
|
| 88 |
|
|
| 89 |
|
|
| 90 |
|
|
| 91 |
|
@param |
| 92 |
|
|
| |
|
| 100% |
Uncovered Elements: 0 (5) |
Complexity: 1 |
Complexity Density: 0.2 |
|
| 93 |
1 |
public void deleteAttachmentByFileByName(String attachmentName)... |
| 94 |
|
{ |
| 95 |
1 |
getDriver().findElement( |
| 96 |
|
By.xpath("//div[@id='attachmentscontent']//a[text()='" + attachmentName |
| 97 |
|
+ "']/../../div[contains(@class, 'xwikibuttonlinks')]/a[contains(@class,'deletelink')]")).click(); |
| 98 |
1 |
getDriver().findElement(By.xpath("//*[@class='xdialog-modal-container']//input[@value='Yes']")).click(); |
| 99 |
1 |
getDriver().waitUntilElementDisappears(By |
| 100 |
|
.xpath("//*[@class='xdialog-modal-container']/*[contains(@class, 'xdialog-box-confirmation')]")); |
| 101 |
1 |
getDriver().waitUntilElementDisappears(By.xpath("//div[@id='attachmentscontent']//a[text()='" |
| 102 |
|
+ attachmentName + "']")); |
| 103 |
1 |
getDriver().waitUntilElementIsVisible(By.xpath("//div[@id='Attachmentspane']")); |
| 104 |
|
} |
| 105 |
|
|
| 106 |
|
|
| 107 |
|
|
| 108 |
|
|
| |
|
| 0% |
Uncovered Elements: 5 (5) |
Complexity: 1 |
Complexity Density: 0.2 |
|
| 109 |
0 |
public void deleteFirstAttachment()... |
| 110 |
|
{ |
| 111 |
0 |
String tmp = getDriver().findElement( |
| 112 |
|
By.xpath("//div[@id='_attachments']/*[1]/div[@class='information']/span[@class='name']")).getText(); |
| 113 |
0 |
getDriver().findElement( |
| 114 |
|
By.xpath("//div[@id='attachmentscontent']//a[text()='" + tmp + "']/../../span[2]/a[@class='deletelink']")) |
| 115 |
|
.click(); |
| 116 |
|
|
| 117 |
0 |
getDriver().findElement(By.xpath("//*[@class='xdialog-modal-container']//input[@value='Yes']")).click(); |
| 118 |
0 |
getDriver().waitUntilElementDisappears(By |
| 119 |
|
.xpath("//*[@class='xdialog-modal-container']/*[contains(@class, 'xdialog-box-confirmation')]")); |
| 120 |
0 |
getDriver().waitUntilElementDisappears(By.xpath("//div[@id='attachmentscontent']//a[text()='" + tmp |
| 121 |
|
+ "']/../../span[2]/a[@class='deletelink']")); |
| 122 |
|
} |
| 123 |
|
|
| 124 |
|
|
| 125 |
|
@return |
| 126 |
|
|
| |
|
| 0% |
Uncovered Elements: 2 (2) |
Complexity: 1 |
Complexity Density: 0.5 |
|
| 127 |
0 |
public int getNumberOfAttachments()... |
| 128 |
|
{ |
| 129 |
0 |
By countLocator = By.cssSelector("#Attachmentstab .itemCount"); |
| 130 |
0 |
return Integer.parseInt(getDriver().findElement(countLocator).getText().replaceAll("[()]", "")); |
| 131 |
|
} |
| 132 |
|
|
| 133 |
|
|
| 134 |
|
|
| 135 |
|
|
| |
|
| 0% |
Uncovered Elements: 4 (4) |
Complexity: 2 |
Complexity Density: 1 |
|
| 136 |
0 |
public void deleteAllAttachments()... |
| 137 |
|
{ |
| 138 |
0 |
while (this.getNumberOfAttachments() > 0) { |
| 139 |
0 |
this.deleteFirstAttachment(); |
| 140 |
|
} |
| 141 |
|
} |
| 142 |
|
|
| |
|
| 0% |
Uncovered Elements: 1 (1) |
Complexity: 1 |
Complexity Density: 1 |
|
| 143 |
0 |
public String getUploaderOfAttachment(String attachmentName)... |
| 144 |
|
{ |
| 145 |
0 |
return getDriver().findElement( |
| 146 |
|
By.xpath("//div[@id='attachmentscontent']//a[text()='" + attachmentName |
| 147 |
|
+ "']/../../div[@class='meta']/span[@class='publisher']/span[@class='wikilink']")).toString(); |
| 148 |
|
} |
| 149 |
|
|
| |
|
| 100% |
Uncovered Elements: 0 (1) |
Complexity: 1 |
Complexity Density: 1 |
|
| 150 |
4 |
public String getLatestVersionOfAttachment(String attachmentName)... |
| 151 |
|
{ |
| 152 |
4 |
return getDriver().findElement( |
| 153 |
|
By.xpath("//div[@id='attachmentscontent']//a[text()= '" + attachmentName |
| 154 |
|
+ "']/../../span[@class='version']/a")).getText(); |
| 155 |
|
} |
| 156 |
|
|
| |
|
| 0% |
Uncovered Elements: 1 (1) |
Complexity: 1 |
Complexity Density: 1 |
|
| 157 |
0 |
public String getSizeOfAttachment(String attachmentName)... |
| 158 |
|
{ |
| 159 |
0 |
return getDriver().findElement( |
| 160 |
|
By.xpath("//div[@id='attachmentscontent']//a[text()='" + attachmentName |
| 161 |
|
+ "']/../../div[@class='meta']/span[@class='size']")).toString().replaceAll("[()]", ""); |
| 162 |
|
|
| 163 |
|
} |
| 164 |
|
|
| |
|
| 0% |
Uncovered Elements: 1 (1) |
Complexity: 1 |
Complexity Density: 1 |
|
| 165 |
0 |
public String getDateOfLastUpload(String attachmentName)... |
| 166 |
|
{ |
| 167 |
0 |
return getDriver().findElement( |
| 168 |
|
By.xpath("//div[@id='attachmentscontent']//a[text()='" + attachmentName |
| 169 |
|
+ "']/../../div[@class='meta']/span[@class='date']")).toString().replaceFirst("on", ""); |
| 170 |
|
} |
| 171 |
|
|
| |
|
| 75% |
Uncovered Elements: 1 (4) |
Complexity: 2 |
Complexity Density: 0.5 |
|
| 172 |
1 |
public boolean attachmentExistsByFileName(String attachmentName)... |
| 173 |
|
{ |
| 174 |
1 |
try { |
| 175 |
1 |
getDriver().findElement( |
| 176 |
|
By.xpath("//a[@title = 'Download this attachment' and . = '" + attachmentName + "']")); |
| 177 |
|
} catch (NoSuchElementException e) { |
| 178 |
0 |
return false; |
| 179 |
|
} |
| 180 |
1 |
return true; |
| 181 |
|
} |
| 182 |
|
} |