001/* 002 * (C) Copyright 2015 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 */ 019package org.nuxeo.functionaltests.forms; 020 021import org.openqa.selenium.WebDriver; 022import org.openqa.selenium.WebElement; 023import org.openqa.selenium.support.ui.Select; 024 025/** 026 * Element representing a select many directory widget. 027 * 028 * @since 7.4 029 */ 030public class SelectManyDirectoryWidgetElement extends WidgetElement { 031 032 public SelectManyDirectoryWidgetElement(WebDriver driver, String id) { 033 super(driver, id); 034 } 035 036 /** 037 * Overridden to make sure the select element is reloaded correctly (for use cases where a selection triggers a 038 * submit of the form in ajax). 039 * 040 * @since 8.1 041 */ 042 @Override 043 public void setInputValue(String value) { 044 Select select = new Select(getInputElement()); 045 if (value != null) { 046 String[] split = value.split(","); 047 for (String v : split) { 048 select = new Select(getInputElement()); 049 select.selectByVisibleText(v); 050 } 051 } 052 } 053 054 @Override 055 public void setInput(WebElement elt, String value) { 056 throw new UnsupportedOperationException("Use #setInputValue(String) instead"); 057 } 058 059}