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