001/* 002 * (C) Copyright 2011 Nuxeo SA (http://nuxeo.com/) and others. 003 * 004 * Licensed under the Apache License, Version 2.0 (the "License"); 005 * you may not use this file except in compliance with the License. 006 * You may obtain a copy of the License at 007 * 008 * http://www.apache.org/licenses/LICENSE-2.0 009 * 010 * Unless required by applicable law or agreed to in writing, software 011 * distributed under the License is distributed on an "AS IS" BASIS, 012 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 013 * See the License for the specific language governing permissions and 014 * limitations under the License. 015 * 016 * Contributors: 017 * Thierry Delprat 018 */ 019 020package org.nuxeo.functionaltests.pages.admincenter; 021 022import org.nuxeo.functionaltests.pages.LoginPage; 023import org.openqa.selenium.By; 024import org.openqa.selenium.WebDriver; 025import org.openqa.selenium.WebElement; 026 027public class SystemHomePage extends AdminCenterBasePage { 028 029 public static final String HOST_SUBTAB = "Host"; 030 031 public static final String SETUP_SUBTAB = "Setup"; 032 033 private static final int RESTART_TIMEOUT_MINUTES = 10; 034 035 public SystemHomePage(WebDriver driver) { 036 super(driver); 037 } 038 039 public LoginPage restart() { 040 if (!HOST_SUBTAB.equals(getSelectedSubTab())) { 041 selectSubTab(HOST_SUBTAB); 042 } 043 By restartLocator = By.xpath("//input[@type='submit' and @value='Restart server']"); 044 findElementWaitUntilEnabledAndClick(restartLocator); 045 046 findElementWithTimeout(By.id("username"), RESTART_TIMEOUT_MINUTES * 60 * 1000); 047 return asPage(LoginPage.class); 048 } 049 050 public boolean setConfig(String id, String value) { 051 if (!SETUP_SUBTAB.equals(getSelectedSubTab())) { 052 selectSubTab(SETUP_SUBTAB); 053 } 054 WebElement input = findElementWithTimeout(By.xpath("//td[@id='" + id + "']/input")); 055 if (input != null) { 056 input.sendKeys(value); 057 return true; 058 } 059 return false; 060 } 061 062 public String getConfig(String id) { 063 if (!SETUP_SUBTAB.equals(getSelectedSubTab())) { 064 selectSubTab(SETUP_SUBTAB); 065 } 066 WebElement input = findElementWithTimeout(By.xpath("//td[@id='" + id + "']/input")); 067 if (input != null) { 068 return input.getAttribute("value"); 069 } 070 return null; 071 } 072 073}