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.AbstractPage; 023import org.openqa.selenium.By; 024import org.openqa.selenium.WebDriver; 025import org.openqa.selenium.WebElement; 026 027public class PackageListingPage extends AbstractPage { 028 029 public PackageListingPage(WebDriver driver) { 030 super(driver); 031 } 032 033 public WebElement getPackageLink(String packageId) { 034 String xpath = "id('row_" + packageId + "')//a[contains(@class ,'button')]"; 035 return findElementWithTimeout(By.xpath(xpath), 20 * 1000); 036 } 037 038 public WebElement getPackageDownloadLink(String packageId) { 039 WebElement link = getPackageLink(packageId); 040 if (link != null) { 041 if (link.getText().trim().toLowerCase().startsWith("download")) { 042 return link; 043 } 044 } 045 return null; 046 } 047 048 public WebElement getPackageInstallLink(String packageId) { 049 WebElement link = getPackageLink(packageId); 050 if (link != null) { 051 if (link.getText().trim().toLowerCase().startsWith("install")) { 052 return link; 053 } 054 } 055 return null; 056 } 057 058 public WebElement download(String packageId) { 059 System.out.println(driver.getCurrentUrl()); 060 WebElement downloadLink = getPackageDownloadLink(packageId); 061 if (downloadLink != null) { 062 downloadLink.click(); 063 return getPackageInstallLink(packageId); 064 } 065 return null; 066 } 067 068 public PackageInstallationScreen getInstallationScreen(String packageId) { 069 WebElement installLink = getPackageInstallLink(packageId); 070 if (installLink == null) { 071 return null; 072 } 073 installLink.click(); 074 return asPage(PackageInstallationScreen.class); 075 } 076 077 public UpdateCenterPage exit() { 078 driver.switchTo().defaultContent(); 079 return asPage(UpdateCenterPage.class); 080 } 081 082}