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

File CommentForm.java

 

Coverage histogram

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

Code metrics

2
13
8
1
115
45
9
0.69
1.62
8
1.12

Classes

Class Line # Actions
CommentForm 31 13 0% 9 2
0.913043591.3%
 

Contributing tests

This file is covered by 8 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.test.ui.po;
21   
22    import org.openqa.selenium.By;
23    import org.openqa.selenium.WebElement;
24   
25    /**
26    * Represents the form used to add, edit or reply to a comment.
27    *
28    * @version $Id: e9b5cc6525ed66accbf6b3718287b234f9195720 $
29    * @since 4.0M1
30    */
 
31    public class CommentForm extends BaseElement
32    {
33    /**
34    * The locator to the form.
35    */
36    private By containerLocator;
37   
38    /**
39    * Creates a new form instance.
40    *
41    * @param containerLocator the locator to the form
42    */
 
43  13 toggle public CommentForm(By containerLocator)
44    {
45  13 this.containerLocator = containerLocator;
46    }
47   
 
48  35 toggle private WebElement getContainer()
49    {
50  35 return getDriver().findElement(this.containerLocator);
51    }
52   
53    /**
54    * @return the field used to input the comment content
55    */
 
56  16 toggle public WebElement getContentField()
57    {
58  16 return getContainer().findElement(By.tagName("textarea"));
59    }
60   
61    /**
62    * Clicks on the preview button and waits for the preview to be ready.
63    *
64    * @return the element that wraps the content preview
65    */
 
66  3 toggle public WebElement clickPreview()
67    {
68  3 getContainer().findElement(By.xpath(".//input[@type = 'button' and @value = 'Preview']")).click();
69  3 By previewLocator = By.className("commentPreview");
70  3 getDriver().waitUntilElementIsVisible(previewLocator);
71  3 return getContainer().findElement(previewLocator);
72    }
73   
74    /**
75    * Clicks on the back button to cancel the preview and show the content text area
76    */
 
77  1 toggle public void clickBack()
78    {
79  1 getContainer().findElement(By.xpath(".//input[@type = 'button' and @value = 'Back']")).click();
80    }
81   
82    /**
83    * Clicks on the submit button and waits for the operation to take place. The effect depends on the actual form. It
84    * could add a new comment, a reply to an existing comment or update an existing comment.
85    */
 
86  5 toggle public void clickSubmit()
87    {
88  5 clickSubmit(true);
89    }
90   
91    /**
92    * Clicks on the submit button and optionally waits for the operation to take place. The effect depends on the
93    * actual form. It could add a new comment, a reply to an existing comment or update an existing comment.
94    * <p>
95    * Note: Use this method when JavaScript is disabled and the submit is not done asynchronously.
96    *
97    * @param wait {@code true} to wait for the success notification, {@code false} otherwise
98    */
 
99  12 toggle public void clickSubmit(boolean wait)
100    {
101  12 getContainer().findElement(By.xpath(".//input[@type = 'submit']")).click();
102  12 if (wait) {
103    // The submit is done asynchronously so we have to wait for the success notification.
104  11 waitForNotificationSuccessMessage("Comment posted");
105    }
106    }
107   
108    /**
109    * Clicks on the cancel button.
110    */
 
111  0 toggle public void clickCancel()
112    {
113  0 getContainer().findElement(By.className("cancel")).click();
114    }
115    }