001/*
002 * (C) Copyright 2011 Nuxeo SA (http://nuxeo.com/) and contributors.
003 *
004 * All rights reserved. This program and the accompanying materials
005 * are made available under the terms of the GNU Lesser General Public License
006 * (LGPL) version 2.1 which accompanies this distribution, and is available at
007 * http://www.gnu.org/licenses/lgpl.html
008 *
009 * This library is distributed in the hope that it will be useful,
010 * but WITHOUT ANY WARRANTY; without even the implied warranty of
011 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
012 * Lesser General Public License for more details.
013 *
014 * Contributors:
015 *     Thierry Delprat
016 */
017package org.nuxeo.functionaltests.pages.wizard;
018
019import org.nuxeo.functionaltests.pages.LoginPage;
020import org.openqa.selenium.By;
021import org.openqa.selenium.NoSuchElementException;
022import org.openqa.selenium.WebDriver;
023import org.openqa.selenium.WebElement;
024
025public class SummaryWizardPage extends WizardPage {
026
027    private static final int RESTART_TIMEOUT_MINUTES = 10;
028
029    public SummaryWizardPage(WebDriver driver) {
030        super(driver);
031    }
032
033    public LoginPage restart() {
034        nav(WizardPage.class, "Start Nuxeo");
035        try {
036            findElementWithTimeout(By.id("username"), RESTART_TIMEOUT_MINUTES * 60 * 1000);
037            return asPage(LoginPage.class);
038        } catch (NoSuchElementException e) {
039            String currentUrl = driver.getCurrentUrl();
040            throw new NoSuchElementException(
041                    String.format("Unable to find login screen after %s minutes, currentUrl=%s",
042                            RESTART_TIMEOUT_MINUTES, currentUrl), e);
043        }
044    }
045
046    public String getRegistration() {
047        WebElement el = findElementWithTimeout(By.id("CLID"));
048        if (el != null) {
049            return el.getText();
050        }
051        return null;
052    }
053
054}