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