001/*
002 * (C) Copyright 2014 Nuxeo SA (http://nuxeo.com/) and others.
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-2.1.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 *     Thomas Roger
016 */
017
018package org.nuxeo.functionaltests.pages.admincenter.monitoring;
019
020import java.util.ArrayList;
021import java.util.List;
022
023import org.openqa.selenium.By;
024import org.openqa.selenium.WebDriver;
025import org.openqa.selenium.WebElement;
026
027/**
028 * @since 6.0
029 */
030public class LogsPage extends MonitoringPage {
031
032    public LogsPage(WebDriver driver) {
033        super(driver);
034    }
035
036    public List<String> getServerLogFileNames() {
037        List<WebElement> serverLogTabs = getServerLogTabs();
038        List<String> fileNames = new ArrayList<>();
039        for (WebElement element : serverLogTabs) {
040            fileNames.add(element.getText());
041        }
042        return fileNames;
043    }
044
045    protected List<WebElement> getServerLogTabs() {
046        return findElementsWithTimeout(By.xpath("//div[@class='tabsBar subtabsBar']//li"));
047    }
048
049    public LogsPage selectServerLogFileTab(String serverLogFileName) {
050        List<WebElement> serverLogTabs = getServerLogTabs();
051        for (WebElement element : serverLogTabs) {
052            if (serverLogFileName.equals(element.getText())) {
053                element.click();
054            }
055        }
056        return asPage(LogsPage.class);
057    }
058
059    public WebElement getDownloadButton(String serverLogFileName) {
060        String downloadButtonValue = "Download " + serverLogFileName;
061        return findElementWithTimeout(By.xpath("//input[@value='" + downloadButtonValue + "']"));
062    }
063
064}