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 * <a href="mailto:[email protected]">Guillaume</a> 018 * Yannis JULIENNE 019 */ 020package org.nuxeo.functionaltests.fragment; 021 022import org.nuxeo.functionaltests.Locator; 023import org.nuxeo.functionaltests.Required; 024import org.nuxeo.functionaltests.forms.Select2WidgetElement; 025import org.openqa.selenium.By; 026import org.openqa.selenium.WebDriver; 027import org.openqa.selenium.WebElement; 028import org.openqa.selenium.support.FindBy; 029 030/** 031 * @since 5.9.3 032 */ 033public class NewVocabularyEntryForm extends WebFragmentImpl { 034 035 @FindBy(id = "addEntryView:addEntryForm:nxl_l10nsubjects_vocabulary:nxw_l10nxvocabulary_label_en") 036 @Required 037 private WebElement englishLabelInput; 038 039 @FindBy(id = "addEntryView:addEntryForm:nxl_l10nsubjects_vocabulary:nxw_l10nxvocabulary_label_fr") 040 @Required 041 private WebElement frenchLabelInput; 042 043 @FindBy(id = "addEntryView:addEntryForm:nxl_l10nsubjects_vocabulary:nxw_l10nxvocabulary_id") 044 @Required 045 private WebElement idInput; 046 047 @FindBy(id = "s2id_addEntryView:addEntryForm:nxl_l10nsubjects_vocabulary:nxw_parent_select2") 048 private WebElement newParentSuggestion; 049 050 @FindBy(id = "addEntryView:addEntryForm:nxl_l10nsubjects_vocabulary:nxw_l10nxvocabulary_obsolete_checkbox:0") 051 @Required 052 private WebElement notObsoleteInput; 053 054 @FindBy(id = "addEntryView:addEntryForm:nxl_l10nsubjects_vocabulary:nxw_l10nxvocabulary_obsolete_checkbox:1") 055 @Required 056 private WebElement obsoleteInput; 057 058 @FindBy(id = "addEntryView:addEntryForm:nxl_l10nsubjects_vocabulary:nxw_l10nxvocabulary_order") 059 @Required 060 private WebElement orderInput; 061 062 public NewVocabularyEntryForm(WebDriver driver, WebElement element) { 063 super(driver, element); 064 } 065 066 public void save() { 067 Locator.waitUntilEnabledAndClick(getElement().findElement(By.xpath("//input[@value='Create']"))); 068 } 069 070 public void setNewVocabularyEnglishLabel(final String vocabularyEnglishLabel) { 071 englishLabelInput.sendKeys(vocabularyEnglishLabel); 072 } 073 074 public void setNewVocabularyFrenchLabel(final String vocabularyFrenchLabel) { 075 frenchLabelInput.sendKeys(vocabularyFrenchLabel); 076 } 077 078 public void setNewVocabularyId(final String vocabularyId) { 079 idInput.sendKeys(vocabularyId); 080 } 081 082 public void setNewVocabularyObsolete(final boolean obsolete) { 083 if (obsolete) { 084 Locator.waitUntilEnabledAndClick(obsoleteInput); 085 } else { 086 Locator.waitUntilEnabledAndClick(notObsoleteInput); 087 } 088 } 089 090 public void setNewVocabularyOrder(final int vocabularyOrder) { 091 orderInput.clear(); 092 orderInput.sendKeys(vocabularyOrder + ""); 093 } 094 095 public void setNewVocabularyParentId(final String parentLabelPath) { 096 Select2WidgetElement select2 = new Select2WidgetElement(driver, newParentSuggestion, false); 097 select2.selectValue(parentLabelPath); 098 } 099 100}