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.Required; 023import org.openqa.selenium.By; 024import org.openqa.selenium.WebDriver; 025import org.openqa.selenium.WebElement; 026import org.openqa.selenium.support.FindBy; 027 028public class UpdateCenterPage extends AdminCenterBasePage { 029 030 @Required 031 @FindBy(linkText = "Packages from Nuxeo Marketplace") 032 WebElement packagesFromNuxeoMarketPlaceLink; 033 034 @Required 035 @FindBy(linkText = "Nuxeo Studio") 036 WebElement packagesFromNuxeoStudioLink; 037 038 public UpdateCenterPage(WebDriver driver) { 039 super(driver); 040 } 041 042 protected static void wait(int nbSeconds) { 043 try { 044 Thread.sleep(nbSeconds * 1000); 045 } catch (InterruptedException e) { 046 Thread.currentThread().interrupt(); 047 throw new RuntimeException(e); 048 } 049 } 050 051 public PackageListingPage getPackageListingPage() { 052 boolean iframeFound = IFrameHelper.focusOnWEIFrame(driver); 053 assert(iframeFound); 054 WebElement body = findElementWithTimeout(By.tagName("body")); // wait for IFrame Body 055 assert(body != null); 056 PackageListingPage page = asPage(PackageListingPage.class); 057 WebElement listing = findElementWithTimeout(By.xpath("//table[@class='packageListing']")); 058 assert(listing != null); 059 return page; 060 } 061 062 public UpdateCenterPage getPackagesFromNuxeoMarketPlace() { 063 064 packagesFromNuxeoMarketPlaceLink.click(); 065 wait(1); 066 return asPage(UpdateCenterPage.class); 067 } 068 069 public UpdateCenterPage getPackagesFromNuxeoStudio() { 070 packagesFromNuxeoStudioLink.click(); 071 wait(1); 072 return asPage(UpdateCenterPage.class); 073 } 074 075 public boolean removePlatformFilterOnMarketPlacePage() { 076 WebElement chk = findElementWithTimeout(By.xpath("(.//*/input[@type='checkbox'])[2]")); 077 if (chk == null) { 078 return false; 079 } 080 if ("true".equals(chk.getAttribute("checked"))) { 081 chk.click(); 082 wait(2); 083 } 084 return true; 085 } 086}