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 } 047 } 048 049 public PackageListingPage getPackageListingPage() { 050 boolean iframeFound = IFrameHelper.focusOnWEIFrame(driver); 051 assert(iframeFound); 052 WebElement body = findElementWithTimeout(By.tagName("body")); // wait for IFrame Body 053 assert(body != null); 054 PackageListingPage page = asPage(PackageListingPage.class); 055 WebElement listing = findElementWithTimeout(By.xpath("//table[@class='packageListing']")); 056 assert(listing != null); 057 return page; 058 } 059 060 public UpdateCenterPage getPackagesFromNuxeoMarketPlace() { 061 062 packagesFromNuxeoMarketPlaceLink.click(); 063 wait(1); 064 return asPage(UpdateCenterPage.class); 065 } 066 067 public UpdateCenterPage getPackagesFromNuxeoStudio() { 068 packagesFromNuxeoStudioLink.click(); 069 wait(1); 070 return asPage(UpdateCenterPage.class); 071 } 072 073 public boolean removePlatformFilterOnMarketPlacePage() { 074 WebElement chk = findElementWithTimeout(By.xpath("(.//*/input[@type='checkbox'])[2]")); 075 if (chk == null) { 076 return false; 077 } 078 if ("true".equals(chk.getAttribute("checked"))) { 079 chk.click(); 080 wait(2); 081 } 082 return true; 083 } 084}