1. Project Clover database Tue Dec 20 2016 21:24:09 CET
  2. Package org.xwiki.administration.test.po

File ImportAdministrationSectionPage.java

 

Coverage histogram

../../../../../img/srcFileCovDistChart9.png
38% of files have more coverage

Code metrics

0
23
9
1
117
74
9
0.39
2.56
9
1

Classes

Class Line # Actions
ImportAdministrationSectionPage 38 23 0% 9 3
0.9062590.6%
 

Contributing tests

This file is covered by 5 tests. .

Source view

1    /*
2    * See the NOTICE file distributed with this work for additional
3    * information regarding copyright ownership.
4    *
5    * This is free software; you can redistribute it and/or modify it
6    * under the terms of the GNU Lesser General Public License as
7    * published by the Free Software Foundation; either version 2.1 of
8    * the License, or (at your option) any later version.
9    *
10    * This software is distributed in the hope that it will be useful,
11    * but WITHOUT ANY WARRANTY; without even the implied warranty of
12    * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
13    * Lesser General Public License for more details.
14    *
15    * You should have received a copy of the GNU Lesser General Public
16    * License along with this software; if not, write to the Free
17    * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
18    * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
19    */
20    package org.xwiki.administration.test.po;
21   
22    import java.net.URL;
23    import java.util.ArrayList;
24    import java.util.List;
25   
26    import org.openqa.selenium.By;
27    import org.openqa.selenium.WebElement;
28    import org.openqa.selenium.support.FindBy;
29    import org.xwiki.test.ui.po.ConfirmationModal;
30    import org.xwiki.test.ui.po.ViewPage;
31   
32    /**
33    * Represents the actions possible on the Administration Import Page.
34    *
35    * @version $Id: d4c21c96554813a600f93cf647021a9aa75debc7 $
36    * @since 4.2M1
37    */
 
38    public class ImportAdministrationSectionPage extends ViewPage
39    {
40    @FindBy(id = "packagelistcontainer")
41    private WebElement packageList;
42   
43    @FindBy(id = "xwikiuploadfile")
44    private WebElement uploadFileInputField;
45   
46    @FindBy(xpath = "//*[@id='attachform']//input[@type='submit']")
47    private WebElement uploadFileSubmit;
48   
49    @FindBy(xpath = "//input[@value='Import']")
50    private WebElement importPackageLink;
51   
 
52  0 toggle public static ImportAdministrationSectionPage gotoPage()
53    {
54  0 getUtil().gotoPage("XWiki", "XWikiPreferences", "import", "editor=globaladmin&section=Import");
55  0 return new ImportAdministrationSectionPage();
56    }
57   
 
58  4 toggle public void attachPackage(URL file)
59    {
60  4 this.uploadFileInputField.sendKeys(file.getPath());
61  4 this.uploadFileSubmit.submit();
62    }
63   
 
64  15 toggle public boolean isPackagePresent(String packageName)
65    {
66  15 return getPackageNames().contains(packageName);
67    }
68   
 
69  16 toggle public List<String> getPackageNames()
70    {
71  16 List<String> names = new ArrayList<String>();
72  16 for (WebElement element : getDriver().findElementsWithoutWaiting(
73    By.xpath("//div[@id='packagelistcontainer']//a[@class='package']")))
74    {
75  6 names.add(element.getText());
76    }
77  16 return names;
78    }
79   
 
80  4 toggle public void selectPackage(String packageName)
81    {
82  4 getDriver().findElement(By.linkText(packageName)).click();
83  4 getDriver().waitUntilElementIsVisible(By.id("packageDescription"));
84    }
85   
 
86  3 toggle public void deletePackage(String packageName)
87    {
88  3 String xpath = "//ul[@class='xlist']//a[@class='package' and contains(.,'%s')]/..//a[@class='deletelink']";
89  3 this.packageList.findElement(By.xpath(String.format(xpath, packageName))).click();
90    // Click on ok button
91  3 ConfirmationModal confirmationModal = new ConfirmationModal();
92  3 confirmationModal.clickOk();
93  3 getDriver().waitUntilElementIsVisible(
94    By.xpath("//div[contains(@class,'xnotification-done') and text()='Done!']"));
95  3 getDriver().findElement(By.xpath("//div[contains(@class,'xnotification-done') and text()='Done!']")).click();
96    }
97   
 
98  4 toggle public void importPackage()
99    {
100    // Click submit
101  4 this.importPackageLink.click();
102    // Wait for the "Import successful message"
103  4 getDriver().waitUntilElementIsVisible(By.xpath("//div[@id='packagecontainer']/div[@class='infomessage']"));
104    }
105   
 
106  4 toggle public ViewPage clickImportedPage(String pageName)
107    {
108  4 getDriver().waitUntilElementIsVisible(By.linkText(pageName));
109  4 getDriver().findElement(By.linkText(pageName)).click();
110  4 return new ViewPage();
111    }
112   
 
113  1 toggle public void selectReplaceHistoryOption()
114    {
115  1 getDriver().findElement(By.xpath("//input[@name='historyStrategy' and @value='replace']")).click();
116    }
117    }