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

File LoginPage.java

 

Coverage histogram

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

Code metrics

4
11
5
1
82
45
8
0.73
2.2
5
1.6

Classes

Class Line # Actions
LoginPage 32 11 0% 8 4
0.880%
 

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.WebElement;
23    import org.openqa.selenium.support.FindBy;
24    import org.xwiki.test.ui.TestUtils;
25   
26    /**
27    * Represents the actions possible on the Login page.
28    *
29    * @version $Id: da4d2cbd838a6e9a9805175da1abae024e997816 $
30    * @since 3.2M3
31    */
 
32    public class LoginPage extends ViewPage
33    {
34    @FindBy(id = "j_username")
35    private WebElement usernameText;
36   
37    @FindBy(id = "j_password")
38    private WebElement passwordText;
39   
40    @FindBy(id = "rememberme")
41    private WebElement rememberMeCheckbox;
42   
43    @FindBy(xpath = "//input[@type='submit' and @value='Log-in']")
44    private WebElement submitButton;
45   
46    @FindBy(xpath = "//div[@class='errormessage']")
47    private WebElement loginErrorDiv;
48   
 
49  0 toggle public static LoginPage gotoPage()
50    {
51  0 getUtil().gotoPage("XWiki", "XWikiLogin", "login");
52  0 return new LoginPage();
53    }
54   
 
55  6 toggle public void loginAsAdmin()
56    {
57  6 loginAs(TestUtils.ADMIN_CREDENTIALS.getUserName(), TestUtils.ADMIN_CREDENTIALS.getPassword(), true);
58    }
59   
 
60  9 toggle public void loginAs(String username, String password, boolean rememberMe)
61    {
62    // In order to have good performance, don't log in again if the user is already logged-in.
63  9 if (!isAuthenticated() || !getCurrentUser().equals(username)) {
64  9 this.usernameText.sendKeys(username);
65  9 this.passwordText.sendKeys(password);
66  9 if (rememberMe) {
67  6 this.rememberMeCheckbox.click();
68    }
69  9 this.submitButton.click();
70    }
71    }
72   
 
73  3 toggle public void loginAs(String username, String password)
74    {
75  3 loginAs(username, password, false);
76    }
77   
 
78  2 toggle public boolean hasInvalidCredentialsErrorMessage()
79    {
80  2 return this.loginErrorDiv.getText().equals("Error: Invalid credentials");
81    }
82    }