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

File TaggablePage.java

 

Coverage histogram

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

Code metrics

2
14
5
1
97
43
6
0.43
2.8
5
1.2

Classes

Class Line # Actions
TaggablePage 35 14 0% 6 2
0.904761990.5%
 

Contributing tests

This file is covered by 10 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.tag.test.po;
21   
22    import java.util.List;
23   
24    import org.openqa.selenium.By;
25    import org.openqa.selenium.WebElement;
26    import org.openqa.selenium.support.FindBy;
27    import org.xwiki.test.ui.po.ViewPage;
28   
29    /**
30    * Models a view page that can be tagged.
31    *
32    * @version $Id: 59e017374c3adcd1e213a40ce03f2b903bdbe9c7 $
33    * @since 4.2M1
34    */
 
35    public class TaggablePage extends ViewPage
36    {
37    /**
38    * The element that contains all the page tags.
39    */
40    @FindBy(id = "xdocTags")
41    private WebElement tagsContainer;
42   
43    /**
44    * @return {@code true} if this page has the specified tag, {@code false} otherwise
45    */
 
46  33 toggle public boolean hasTag(String tagName)
47    {
48  33 return getDriver().findElementsWithoutWaiting(this.tagsContainer, getTagLocator(tagName)).size() > 0;
49    }
50   
51    /**
52    * @param tagName a tag name
53    * @return the XPATH expression locating the specified tag
54    */
 
55  36 toggle private By getTagLocator(String tagName)
56    {
57  36 return By.xpath("//*[@class = 'tag' and . = '" + tagName + "']");
58    }
59   
60    /**
61    * Removes the specified tag from this page.
62    *
63    * @param tagName the name of the tag to remove
64    * @return {@code true} if the tag was found, {@code false} otherwise
65    */
 
66  3 toggle public boolean removeTag(String tagName)
67    {
68  3 List<WebElement> toDelete = getDriver().findElementsWithoutWaiting(this.tagsContainer,
69    By.xpath("//a[contains(@href, '&tag=" + tagName + "') and . = 'X']"));
70  3 if (toDelete.size() > 0) {
71  3 toDelete.get(0).click();
72  3 getDriver().waitUntilElementDisappears(getTagLocator(tagName));
73  3 return true;
74    }
75  0 return false;
76    }
77   
78    /**
79    * Opens the panel to add new tags to this page.
80    *
81    * @return the panel that can be used to add new tags
82    */
 
83  12 toggle public AddTagsPane addTags()
84    {
85  12 this.tagsContainer.findElement(By.linkText("[+]")).click();
86  12 getDriver().waitUntilElementDisappears(By.xpath("//*[@id = 'xdocTags']//a[. = '[+]']"));
87  12 return new AddTagsPane();
88    }
89   
 
90  2 toggle public TagPage clickOnTag(String tagName)
91    {
92  2 WebElement tag = getDriver().findElementWithoutWaiting(
93    By.xpath("//span[@class='tag']/a[. = '" + tagName + "' ]"));
94  2 tag.click();
95  2 return new TagPage();
96    }
97    }