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

File AnnotationsLabel.java

 

Coverage histogram

../../../../../img/srcFileCovDistChart8.png
54% of files have more coverage

Code metrics

0
29
10
1
124
77
10
0.34
2.9
10
1

Classes

Class Line # Actions
AnnotationsLabel 36 29 0% 10 10
0.7435897674.4%
 

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.annotation.test.po;
21   
22    import org.openqa.selenium.By;
23    import org.openqa.selenium.Keys;
24    import org.openqa.selenium.WebElement;
25    import org.openqa.selenium.interactions.Actions;
26    import org.openqa.selenium.support.FindBy;
27    import org.xwiki.test.ui.po.BaseElement;
28   
29    /**
30    * Implements the Annotation window that appears when selecting an annotation
31    *
32    * @version $Id: e3d9710997476bbb8c3128fe957fbead9ee8a3f5 $
33    * @since 4.2M1
34    */
35   
 
36    public class AnnotationsLabel extends BaseElement
37    {
38   
39    @FindBy(xpath = "//a[@title='Delete this annotation']")
40    private WebElement deleteAnnotation;
41   
42    @FindBy(xpath = "//span[@class='annotationAuthor']")
43    private WebElement annotationAuthor;
44   
45    @FindBy(xpath = "annotationDate")
46    private WebElement annotationDate;
47   
 
48  4 toggle private void hoverOnAnnotationByText(String searchText)
49    {
50  4 hoverOnAnnotationById(getAnnotationIdByText(searchText));
51    }
52   
 
53  8 toggle private void hoverOnAnnotationById(String annotationId)
54    {
55  8 WebElement annotationIcon = getDriver().findElement(By.id(annotationId));
56   
57    // Move mouse to annotation icon
58  8 Actions builder = new Actions(getDriver());
59  8 builder.moveToElement(annotationIcon).build().perform();
60   
61  8 getDriver().waitUntilElementIsVisible(By.className("annotation-box-view"));
62    }
63   
 
64  4 toggle private void showAnnotationById(String idText)
65    {
66  4 hoverOnAnnotationById(idText);
67    }
68   
 
69  0 toggle private void showAnnotationByText(String searchText)
70    {
71  0 showAnnotationById(getAnnotationIdByText(searchText));
72    }
73   
 
74  0 toggle public void deleteAnnotationByText(String searchText)
75    {
76  0 this.deleteAnnotationById(this.getAnnotationIdByText(searchText));
77    }
78   
 
79  4 toggle public void deleteAnnotationById(String idText)
80    {
81  4 this.showAnnotationById(idText);
82  4 this.deleteAnnotation.click();
83  4 getDriver().waitUntilElementIsVisible(By.xpath("//input[@value='Yes']"));
84  4 getDriver().findElement(By.xpath("//input[@value='Yes']")).click();
85    }
86   
 
87  0 toggle public String getAnnotationsAuthorByText(String searchText)
88    {
89  0 this.hoverOnAnnotationByText(searchText);
90  0 return this.annotationAuthor.getText();
91    }
92   
 
93  0 toggle public String getAnnotationAuthorById(String idText)
94    {
95  0 this.showAnnotationById(idText);
96  0 return this.annotationAuthor.getText();
97    }
98   
 
99  8 toggle public String getAnnotationIdByText(String searchText)
100    {
101  8 getDriver().waitUntilElementIsVisible(By.xpath("//span[contains(.,'" + searchText + "')]"));
102  8 WebElement annotation = getDriver().findElement(By.xpath("//span[contains(.,'" + searchText + "')]"));
103  8 String classId = annotation.getAttribute("class");
104  8 classId = classId.split("\\s+")[1];
105  8 return classId;
106    }
107   
 
108  4 toggle public String getAnnotationContentByText(String searchText)
109    {
110  4 hoverOnAnnotationByText(searchText);
111  4 getDriver().waitUntilElementIsVisible(By.xpath("//div[@class='annotationText']/p"));
112  4 String annotationContent =
113    getDriver().findElement(By.xpath("//*[@class='annotation-bubble']//div[@class='annotationText']/p"))
114    .getText();
115  4 WebElement body = getDriver().findElement(By.id("body"));
116   
117    // It seems that hovering over the small yellow icon sends 2 requests, and one ESC is not enough to make the
118    // window disappear
119  4 body.sendKeys(Keys.ESCAPE);
120  4 body.sendKeys(Keys.ESCAPE);
121  4 getDriver().waitUntilElementDisappears(By.className("annotation-box-view"));
122  4 return annotationContent;
123    }
124    }