Class | Line # | Actions | |||||
---|---|---|---|---|---|---|---|
NewPagePanel | 33 | 8 | 0% | 2 | 0 |
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.panels.test.po; | |
21 | ||
22 | import org.openqa.selenium.WebElement; | |
23 | import org.openqa.selenium.support.FindBy; | |
24 | import org.xwiki.test.ui.po.CreatePagePage; | |
25 | import org.xwiki.test.ui.po.ViewPage; | |
26 | ||
27 | /** | |
28 | * Represents the NewPage panel. | |
29 | * | |
30 | * @version $Id: fe6a740365d017f087c1b5ddea5acd1242df69d2 $ | |
31 | * @since 4.2M1 | |
32 | */ | |
33 | public class NewPagePanel extends ViewPage | |
34 | { | |
35 | /** | |
36 | * The text field used to input the space reference. | |
37 | * <p> | |
38 | * NOTE: We can't find the space name text field by name because there is a meta tag with the same name. We can't | |
39 | * find the space name text field by id either because the create page panel uses random identifiers to prevent | |
40 | * conflicts with the page content. | |
41 | */ | |
42 | @FindBy(xpath = "//input[@type = 'text' and @name = 'spaceReference']") | |
43 | private WebElement spaceNameTextField; | |
44 | ||
45 | /** | |
46 | * The text field used to input the page name. | |
47 | */ | |
48 | @FindBy(xpath = "//input[@type = 'text' and @name = 'name']") | |
49 | private WebElement pageNameTextField; | |
50 | ||
51 | 1 | public static NewPagePanel gotoPage() |
52 | { | |
53 | 1 | getUtil().gotoPage("Panels", "NewPage"); |
54 | 1 | return new NewPagePanel(); |
55 | } | |
56 | ||
57 | /** | |
58 | * Fills the form on the NewPage panel with the given information and submits the form. | |
59 | * | |
60 | * @param spaceReferenceString the string representation of the reference of the space where to create the page | |
61 | * @param pageName the name of page to create | |
62 | * @return the create page form for the specified page | |
63 | */ | |
64 | 1 | public CreatePagePage createPage(String spaceReferenceString, String pageName) |
65 | { | |
66 | // Clean the default space name value. | |
67 | 1 | this.spaceNameTextField.clear(); |
68 | 1 | this.spaceNameTextField.sendKeys(spaceReferenceString); |
69 | 1 | this.pageNameTextField.clear(); |
70 | 1 | this.pageNameTextField.sendKeys(pageName); |
71 | 1 | this.pageNameTextField.submit(); |
72 | 1 | return new CreatePagePage(); |
73 | } | |
74 | } |