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

File SchedulerHomePage.java

 

Coverage histogram

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

Code metrics

0
21
15
1
132
83
15
0.71
1.4
15
1

Classes

Class Line # Actions
SchedulerHomePage 29 21 0% 15 2
0.944444494.4%
 

Contributing tests

This file is covered by 2 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.scheduler.test.po;
21   
22    import org.openqa.selenium.By;
23    import org.openqa.selenium.WebElement;
24    import org.openqa.selenium.support.FindBy;
25    import org.xwiki.scheduler.test.po.editor.SchedulerEditPage;
26    import org.xwiki.test.ui.po.ConfirmationPage;
27    import org.xwiki.test.ui.po.ViewPage;
28   
 
29    public class SchedulerHomePage extends ViewPage
30    {
31    @FindBy(xpath = "//form[@id='newdoc']//input[@type='submit' and @value='Add']")
32    private WebElement addButton;
33   
34    @FindBy(id = "page")
35    private WebElement nameInput;
36   
 
37  2 toggle public static SchedulerHomePage gotoPage()
38    {
39  2 getUtil().gotoPage("Scheduler", "WebHome", "view");
40  2 return new SchedulerHomePage();
41    }
42   
 
43  1 toggle public String getURL()
44    {
45  1 return getUtil().getURL("Scheduler", "WebHome");
46    }
47   
 
48  1 toggle public void setJobName(String jobName)
49    {
50  1 this.nameInput.clear();
51  1 this.nameInput.sendKeys(jobName);
52    }
53   
 
54  1 toggle public SchedulerPage clickJobActionView(String jobName)
55    {
56  1 clickAction(jobName, "View");
57  1 return new SchedulerPage();
58    }
59   
 
60  1 toggle public SchedulerEditPage clickJobActionEdit(String jobName)
61    {
62  1 clickAction(jobName, "Edit");
63  1 return new SchedulerEditPage();
64    }
65   
 
66  1 toggle public ConfirmationPage clickJobActionDelete(String jobName)
67    {
68  1 clickAction(jobName, "Delete");
69  1 return new ConfirmationPage();
70    }
71   
 
72  1 toggle public void clickJobActionSchedule(String jobName)
73    {
74  1 clickAction(jobName, "Schedule");
75    }
76   
 
77  2 toggle public void clickJobActionTrigger(String jobName)
78    {
79  2 clickAction(jobName, "Trigger");
80    }
81   
 
82  1 toggle public void clickJobActionPause(String jobName)
83    {
84  1 clickAction(jobName, "Pause");
85    }
86   
 
87  1 toggle public void clickJobActionResume(String jobName)
88    {
89  1 clickAction(jobName, "Resume");
90    }
91   
 
92  1 toggle public void clickJobActionUnschedule(String jobName)
93    {
94  1 clickAction(jobName, "Unschedule");
95    }
96   
97    /**
98    * Click one of the actin that can be performed on a job.
99    */
 
100  9 toggle private void clickAction(String jobName, String actionLinkName)
101    {
102  9 getDriver().findElement(
103    By.xpath("//tr[td[.='" + jobName + "']]//a[.='" + actionLinkName + "']")).click();
104    }
105   
 
106  1 toggle public SchedulerEditPage clickAdd()
107    {
108  1 this.addButton.click();
109  1 return new SchedulerEditPage();
110    }
111   
112    /**
113    * @return true if the scheduler home page contains an error message or false otherwise. An error message appears
114    * when one of the scheduler actions fails to execute properly.
115    * @since 4.2M1
116    */
 
117  5 toggle public boolean hasError()
118    {
119  5 return getDriver().findElementsWithoutWaiting(
120    By.xpath("//div[contains(@class, 'errormessage')]")).size() > 0;
121    }
122   
123    /**
124    * @return the text of the error message (see {@link #hasError()}
125    * @since 4.2M1
126    */
 
127  0 toggle public String getErrorMessage()
128    {
129  0 return getDriver().findElementWithoutWaiting(
130    By.xpath("//div[contains(@class, 'errormessage')]")).getText();
131    }
132    }