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

File AdministrationPage.java

 

Coverage histogram

../../../../../img/srcFileCovDistChart7.png
64% of files have more coverage

Code metrics

0
35
21
1
240
142
21
0.6
1.67
21
1

Classes

Class Line # Actions
AdministrationPage 35 35 0% 21 21
0.62562.5%
 

Contributing tests

This file is covered by 14 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 org.openqa.selenium.By;
23    import org.openqa.selenium.WebElement;
24    import org.openqa.selenium.support.FindBy;
25    import org.xwiki.model.reference.DocumentReference;
26    import org.xwiki.model.reference.SpaceReference;
27    import org.xwiki.test.ui.po.ViewPage;
28   
29    /**
30    * Represents the actions possible on the main Administration Page.
31    *
32    * @version $Id: 871d76e9eb4f39f8bafaea2cf7a7493ef372514a $
33    * @since 4.2M1
34    */
 
35    public class AdministrationPage extends ViewPage
36    {
37    @FindBy(xpath = "//a[contains(@href, 'section=Localization')]")
38    WebElement localizationLink;
39   
40    @FindBy(xpath = "//a[contains(@href, 'section=Import')]")
41    WebElement importLink;
42   
43    @FindBy(xpath = "//a[contains(@href, 'section=Registration')]")
44    WebElement registrationLink;
45   
46    @FindBy(xpath = "//a[contains(@href, 'section=Users')]")
47    WebElement usersLink;
48   
49    @FindBy(xpath = "//a[contains(@href, 'section=Rights')]")
50    WebElement rightsLink;
51   
52    @FindBy(xpath = "//a[contains(@href, 'section=Annotations')]")
53    WebElement annotationsLink;
54   
55    @FindBy(xpath = "//a[contains(@href, 'section=Extension Manager')]")
56    WebElement extensionsLink;
57   
58    @FindBy(xpath = "//a[contains(@href, 'section=WYSIWYG')]")
59    WebElement wysiwygLink;
60   
61    @FindBy(xpath = "//a[contains(@href, 'section=Elements')]")
62    private WebElement pageElementsLink;
63   
64    @FindBy(xpath = "//a[contains(@href, 'section=Presentation')]")
65    private WebElement presentationLink;
66   
67    @FindBy(id = "goto-select")
68    WebElement spaceAdminSelect;
69   
 
70  31 toggle public static AdministrationPage gotoPage()
71    {
72  31 getUtil().gotoPage(getSpace(), getPage(), "admin");
73  31 return new AdministrationPage();
74    }
75   
76    /**
77    * Redirects to the administration page of a specified space.
78    *
79    * @param spaceReference the space reference
80    * @return the administration page of the specified space
81    * @since 7.2M3
82    */
 
83  4 toggle public static AdministrationPage gotoSpaceAdministrationPage(SpaceReference spaceReference)
84    {
85  4 DocumentReference documentReference = new DocumentReference("WebPreferences", spaceReference);
86  4 getUtil().gotoPage(documentReference, "admin");
87   
88  4 return new AdministrationPage();
89    }
90   
91    /**
92    * Redirects to the administration page of a specified space.
93    *
94    * @param spaceReferenceString the string serialized space reference
95    * @return the administration page of the specified space
96    * @since 7.2M3
97    */
 
98  4 toggle public static AdministrationPage gotoSpaceAdministrationPage(String spaceReferenceString)
99    {
100  4 SpaceReference spaceReference = new SpaceReference(getUtil().resolveSpaceReference(spaceReferenceString));
101  4 return gotoSpaceAdministrationPage(spaceReference);
102    }
103   
 
104  0 toggle public static String getURL()
105    {
106  0 return getUtil().getURL(getSpace(), getPage());
107    }
108   
 
109  31 toggle public static String getSpace()
110    {
111  31 return "XWiki";
112    }
113   
 
114  31 toggle public static String getPage()
115    {
116  31 return "XWikiPreferences";
117    }
118   
 
119  14 toggle public LocalizationAdministrationSectionPage clickLocalizationSection()
120    {
121  14 this.localizationLink.click();
122  14 return new LocalizationAdministrationSectionPage();
123    }
124   
 
125  5 toggle public ImportAdministrationSectionPage clickImportSection()
126    {
127  5 this.importLink.click();
128  5 return new ImportAdministrationSectionPage();
129    }
130   
 
131  0 toggle public AdministrationSectionPage clickRegistrationSection()
132    {
133  0 this.registrationLink.click();
134  0 return new AdministrationSectionPage("register");
135    }
136   
 
137  0 toggle public UsersAdministrationSectionPage clickUsersSection()
138    {
139  0 this.usersLink.click();
140  0 return new UsersAdministrationSectionPage();
141    }
142   
 
143  0 toggle public GlobalRightsAdministrationSectionPage clickGlobalRightsSection()
144    {
145  0 this.rightsLink.click();
146  0 return new GlobalRightsAdministrationSectionPage();
147    }
148   
 
149  0 toggle public AnnotationsPage clickAnnotationsSection()
150    {
151  0 this.annotationsLink.click();
152  0 return new AnnotationsPage();
153    }
154   
 
155  1 toggle public WYSIWYGEditorAdministrationSectionPage clickWYSIWYGEditorSection()
156    {
157  1 this.wysiwygLink.click();
158  1 return new WYSIWYGEditorAdministrationSectionPage();
159    }
160   
161    /**
162    * @since 6.3M1
163    */
 
164  2 toggle public PresentationAdministrationSectionPage clickPresentationSection()
165    {
166  2 this.presentationLink.click();
167  2 return new PresentationAdministrationSectionPage();
168    }
169   
170    /**
171    * Opens the "Page Elements" administration section.
172    *
173    * @return the "Page Elements" administration section
174    */
 
175  0 toggle public PageElementsAdministrationSectionPage clickPageElementsSection()
176    {
177  0 pageElementsLink.click();
178  0 return new PageElementsAdministrationSectionPage();
179    }
180   
181    /**
182    * @since 6.4M2
183    */
 
184  8 toggle public ViewPage clickSection(String categoryName, String sectionName)
185    {
186  8 getDriver().findElement(By.xpath(
187    "//div[contains(@class, 'admin-menu')]"
188    + "/ul/li/span/a[text() = '" + categoryName + "']"
189    + "/../../ul/li/span/a[text() = '" + sectionName + "']")).click();
190  8 return new ViewPage();
191    }
192   
193    /**
194    * @since 6.4M2
195    */
 
196  0 toggle public boolean hasSection(String categoryName, String sectionName)
197    {
198  0 return getDriver().hasElement(By.xpath(
199    "//div[contains(@class, 'admin-menu')]"
200    + "/ul/li/span/a[text() = '" + categoryName + "']"
201    + "/../../ul/li/span/a[text() = '" + sectionName + "']"));
202    }
203   
 
204  23 toggle public boolean hasSection(String sectionName)
205    {
206  23 return getDriver().hasElement(By.xpath("//*[contains(@class, 'admin-menu')]//a[contains(@href, 'section="
207    + sectionName + "')]"));
208    }
209   
210    /**
211    * @since 6.4M2
212    */
 
213  0 toggle public boolean hasNotSection(String categoryName, String sectionName)
214    {
215  0 return getDriver().findElementsWithoutWaiting(By.xpath(
216    "//div[contains(@class, 'admin-menu')]"
217    + "/ul/li/span/a[text() = '" + categoryName + "']"
218    + "/../../ul/li/span/a[text() = '" + sectionName + "']")).size() == 0;
219    }
220   
 
221  11 toggle public boolean hasNotSection(String sectionName)
222    {
223  11 return getDriver().findElementsWithoutWaiting(
224    By.xpath("//*[contains(@class, 'admin-menu')]//a[contains(@href, 'section="
225    + sectionName + "')]")).size() == 0;
226    }
227   
228    /**
229    * Select the space to administer.
230    *
231    * Note that caller of the API need to wait for the page to be loaded since the selection of the page is done
232    * asynchronously with JS.
233    */
 
234  1 toggle public AdministrationPage selectSpaceToAdminister(String spaceName)
235    {
236    // FIXME: actually implement this (and maybe change its signature accordingly) once the new page administration
237    // UI is implemented in http://jira.xwiki.org/browse/XWIKI-12219
238  1 return gotoSpaceAdministrationPage(spaceName);
239    }
240    }