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

File InvitationSenderPage.java

 

Coverage histogram

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

Code metrics

12
28
11
2
149
101
17
0.61
2.55
5.5
1.55

Classes

Class Line # Actions
InvitationSenderPage 38 26 0% 15 3
0.936170293.6%
InvitationSenderPage.InvitationSentPage 131 2 0% 2 0
1.0100%
 

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.invitation.test.po;
21   
22    import java.util.HashMap;
23    import java.util.Map;
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.BasePage;
29    import org.xwiki.test.ui.po.FormElement;
30    import org.xwiki.test.ui.po.TableElement;
31   
32    /**
33    * Represents the actions possible on the invitation sender page.
34    *
35    * @version $Id: bc8b0c6972f55ba0032ca4980c0c9cc318410ebb $
36    * @since 4.2M1
37    */
 
38    public class InvitationSenderPage extends BasePage
39    {
40    @FindBy(id = "invitation-sender-form")
41    private WebElement form;
42   
43    private FormElement formElement;
44   
45    @FindBy(xpath = "//form[@id='invitation-sender-form']/div/div/span/input[@type='submit'][@name='preview']")
46    private WebElement previewButton;
47   
48    @FindBy(xpath = "//form[@id='invitation-sender-form']/div/div/span/input[@type='submit'][@name='sendMail']")
49    private WebElement sendButton;
50   
51    @FindBy(id = "invitation-displaymessage")
52    private WebElement preview;
53   
54    private InvitationMessageDisplayElement previewElement;
55   
 
56  22 toggle public static InvitationSenderPage gotoPage()
57    {
58  22 getUtil().gotoPage(getURL());
59  22 return new InvitationSenderPage();
60    }
61   
 
62  22 toggle public static String getURL()
63    {
64  22 return getUtil().getURL("Invitation", "WebHome");
65    }
66   
 
67  2 toggle public boolean userIsSpammer()
68    {
69  2 for (WebElement error : getDriver().findElementsWithoutWaiting(By.id("invitation-permission-error"))) {
70  1 if (error.getText().equals(
71    "A message which you sent was reported as spam and your privilege to send mail has"
72    + " been suspended pending investigation, we apologize for the inconvenience.")) {
73  1 return true;
74    }
75    }
76  1 return false;
77    }
78   
 
79  12 toggle public void fillInDefaultValues()
80    {
81  12 fillForm("user@localhost.localdomain", "This is a subject line.", "This is my message");
82    }
83   
 
84  18 toggle public void fillForm(final String recipients,
85    final String subjectLine,
86    final String messageBody)
87    {
88  18 Map<String, String> map = new HashMap<String, String>();
89  18 if (recipients != null) {
90  18 map.put("recipients", recipients);
91    }
92  18 if (subjectLine != null) {
93  12 map.put("subjectLine", subjectLine);
94    }
95  18 if (messageBody != null) {
96  13 map.put("messageBody", messageBody);
97    }
98  18 getForm().fillFieldsByName(map);
99    }
100   
 
101  11 toggle public InvitationSentPage send()
102    {
103  11 this.sendButton.click();
104  11 return this.new InvitationSentPage();
105    }
106   
 
107  1 toggle public InvitationMessageDisplayElement preview()
108    {
109  1 this.previewButton.click();
110   
111  1 if (this.previewElement == null) {
112  1 this.previewElement = new InvitationMessageDisplayElement(this.preview);
113    }
114  1 return this.previewElement;
115    }
116   
 
117  18 toggle public FormElement getForm()
118    {
119  18 if (this.formElement == null) {
120  17 this.formElement = new FormElement(this.form);
121    }
122  18 return this.formElement;
123    }
124   
 
125  9 toggle public InvitationFooterElement getFooter()
126    {
127  9 return new InvitationFooterElement();
128    }
129   
130    /** This page represents the invitation app after the send button has been pressed. */
 
131    public class InvitationSentPage extends BasePage
132    {
133    @FindBy(id = "invitation-action-message")
134    private WebElement messageBox;
135   
136    @FindBy(xpath = "//div[@class='message-table']/table")
137    private WebElement table;
138   
 
139  4 toggle public String getMessageBoxContent()
140    {
141  4 return this.messageBox.getText();
142    }
143   
 
144  2 toggle public TableElement getTable()
145    {
146  2 return new TableElement(this.table);
147    }
148    }
149    }