001/* 002 * (C) Copyright 2016 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 * Anahide Tchertchian 018 * Gabriel Barata 019 * Yannis JULIENNE 020 */ 021package org.nuxeo.functionaltests.pages.tabs; 022 023import static org.junit.Assert.assertNotNull; 024import static org.nuxeo.functionaltests.Constants.SECTION_TYPE; 025 026import org.nuxeo.functionaltests.AbstractTest; 027import org.nuxeo.functionaltests.Required; 028import org.nuxeo.functionaltests.contentView.ContentViewElement; 029import org.nuxeo.functionaltests.pages.AbstractPage; 030import org.nuxeo.functionaltests.pages.forms.DublinCoreCreationDocumentFormPage; 031import org.openqa.selenium.By; 032import org.openqa.selenium.NoSuchElementException; 033import org.openqa.selenium.WebDriver; 034import org.openqa.selenium.WebElement; 035import org.openqa.selenium.support.FindBy; 036 037/** 038 * Section content tab. 039 * 040 * @since 8.3 041 */ 042public class SectionContentTabSubPage extends AbstractContentTabSubPage { 043 044 /** 045 * @deprecated since 9.1 not used 046 */ 047 @Deprecated 048 @Required 049 @FindBy(id = "section_content") 050 WebElement contentForm; 051 052 @Required 053 @FindBy(id = "cv_section_content_0_panel") 054 WebElement contentView; 055 056 @FindBy(linkText = "New") 057 WebElement newButton; 058 059 public SectionContentTabSubPage(WebDriver driver) { 060 super(driver); 061 } 062 063 @Override 064 protected WebElement getContentViewElement() { 065 return contentView; 066 } 067 068 public DublinCoreCreationDocumentFormPage getSectionCreatePage() { 069 newButton.click(); 070 WebElement fancyBox = AbstractPage.getFancyBoxContent(); 071 // find the link to doc type that needs to be created 072 WebElement link = fancyBox.findElement(By.linkText(SECTION_TYPE)); 073 assertNotNull(link); 074 link.click(); 075 return asPage(DublinCoreCreationDocumentFormPage.class); 076 } 077 078 public SectionContentTabSubPage unpublishDocument(String documentTitle) { 079 getContentView().selectByTitle(documentTitle).clickOnActionByTitle("Unpublish"); 080 return asPage(SectionContentTabSubPage.class); 081 } 082 083 protected ContentViewElement getElement() { 084 return AbstractTest.getWebFragment(By.id("cv_section_content_0_panel"), ContentViewElement.class); 085 } 086 087 /** 088 * @since 8.3 089 */ 090 public boolean hasNewButton() { 091 try { 092 return newButton.isDisplayed(); 093 } catch (NoSuchElementException e) { 094 return false; 095 } 096 } 097 098 /** 099 * @since 8.3 100 */ 101 public SectionContentTabSubPage refreshContent() { 102 getContentView().getUpperActions().refreshContent(); 103 return asPage(SectionContentTabSubPage.class); 104 } 105 106}