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

File WikiIndexPage.java

 

Coverage histogram

../../../../../img/srcFileCovDistChart10.png
0% of files have more coverage

Code metrics

2
17
6
1
112
57
7
0.41
2.83
6
1.17

Classes

Class Line # Actions
WikiIndexPage 35 17 0% 7 0
1.0100%
 

Contributing tests

This file is covered by 1 test. .

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.wiki.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.WebElement;
27    import org.openqa.selenium.support.FindBy;
28    import org.xwiki.test.ui.po.LiveTableElement;
29   
30    /**
31    * Represents actions that can be done on the WikiManager.WebHome page.
32    *
33    * @version $Id: 4d0056a67e896131fdab42af34a71b17d6c46d99 $
34    */
 
35    public class WikiIndexPage extends ExtendedViewPage
36    {
37    @FindBy(id = "wikis")
38    private WebElement wikisTable;
39   
40    @FindBy(xpath = "//table[@id='wikis']//td[@class='wikiprettyname linkfield typetext']/a\n")
41    private List<WebElement> wikiPrettyNames;
42   
43    @FindBy(id = "tmCreateWiki")
44    private WebElement createWikiMenuButton;
45   
46    /**
47    * The wiki index live table.
48    */
49    private LiveTableElement liveTable = new LiveTableElement("wikis");
50   
51    /**
52    * Opens the home page.
53    */
 
54  8 toggle public static WikiIndexPage gotoPage()
55    {
56  8 getUtil().gotoPage("WikiManager", "WebHome");
57  8 return new WikiIndexPage();
58    }
59   
 
60  5 toggle public List<WikiLink> getWikiPrettyNames()
61    {
62  5 List<WikiLink> list = new ArrayList<>();
63  5 for (WebElement prettyName : wikiPrettyNames) {
64  14 list.add(new WikiLink(prettyName));
65    }
66  5 return list;
67    }
68   
69    /**
70    * @since 6.0M1
71    */
 
72  5 toggle public WikiLink getWikiLink(String wikiName)
73    {
74  5 for (WikiLink link : getWikiPrettyNames()) {
75  14 if (link.getWikiName().equals(wikiName)) {
76  2 return link;
77    }
78    }
79    // We have not found the wiki in the list
80  3 return null;
81    }
82   
 
83  5 toggle @Override
84    public WikiIndexPage waitUntilPageIsLoaded()
85    {
86  5 this.liveTable.waitUntilReady();
87  5 return this;
88    }
89   
90    /**
91    * @since 8.4.3
92    */
 
93  4 toggle public CreateWikiPage createWiki()
94    {
95  4 this.createWikiMenuButton.click();
96  4 return new CreateWikiPage();
97    }
98   
99    /**
100    * @since 8.4.3
101    */
 
102  3 toggle public DeleteWikiPage deleteWiki(String wikiName)
103    {
104    // Note: this can work only if there is not a lot of wikis otherwise the wiki might not be present in the index
105    // because of the pagination.
106    // TODO: improve this by filtering on the livetable first
107  3 WebElement deleteWikiLink = getDriver().findElement(
108    By.xpath(String.format("//a[contains(@class, 'actiondelete') and contains(@href, '%s')]", wikiName)));
109  3 deleteWikiLink.click();
110  3 return new DeleteWikiPage();
111    }
112    }