OpenKeyWord  Build_ID: 457, Datum: 01.02.2020 07:45:48
Dont repeat yourself. - Do it once and only once!
SeSelect.java
1 package okw.gui.adapter.selenium;
2 
3 import java.util.ArrayList;
4 
5 import org.openqa.selenium.WebElement;
6 import org.openqa.selenium.support.ui.Select;
7 
8 import okw.OKW_Const_Sngltn;
9 import okw.gui.OKWLocator;
10 import okw.gui.OKWLocatorBase;
11 
12 /*
13  ==============================================================================
14  Author: Zoltán Hrabovszki <zh@openkeyword.de>
15 
16  Copyright © 2012 - 2019 IT-Beratung Hrabovszki
17  www.OpenKeyWord.de
18  ==============================================================================
19 
20  This file is part of OpenKeyWord.
21 
22  OpenKeyWord is free software: you can redistribute it and/or modify
23  it under the terms of the GNU General Public License as published by
24  the Free Software Foundation, either version 3 of the License, or
25  (at your option) any later version.
26 
27  OpenKeyWord is distributed in the hope that it will be useful,
28  but WITHOUT ANY WARRANTY; without even the implied warranty of
29  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
30  GNU General Public License for more details.
31 
32  You should have received a copy of the GNU General Public License
33  along with OpenKeyWord. If not, see <http://www.gnu.org/licenses/>.
34 
35  Diese Datei ist Teil von OpenKeyWord.
36 
37  OpenKeyWord ist Freie Software: Sie können es unter den Bedingungen
38  der GNU General Public License, wie von der Free Software Foundation,
39  Version 3 der Lizenz oder (nach Ihrer Wahl) jeder späteren
40  veröffentlichten Version, weiterverbreiten und/oder modifizieren.
41 
42  OpenKeyWord wird in der Hoffnung, dass es nützlich sein wird, aber
43  OHNE JEDE GEWÄHRLEISTUNG, bereitgestellt; sogar ohne die implizite
44  Gewährleistung der MARKTFÄHIGKEIT oder EIGNUNG FÜR EINEN BESTIMMTEN ZWECK.
45  Siehe die GNU General Public License für weitere Details.
46 
47  Sie sollten eine Kopie der GNU General Public License zusammen mit
48  OpenKeyWord erhalten haben. Wenn nicht, siehe <http://www.gnu.org/licenses/>.
49 */
50 
51 
141 public class SeSelect extends SeAnyChildWindow
142 {
143 
147  public SeSelect( String Locator, OKWLocatorBase... Locators )
148  {
149  super( Locator, Locators );
150  }
151 
162  @Override
163  public void Select( ArrayList<String> fps_Values )
164  {
165  this.LogFunctionStartDebug( "Select", "fps_Values", fps_Values.toString() );
166 
167  try
168  {
169  // Waiting for the object.
170  // If it does not exist after TimeOut
171  // then the exception OKWGUIObjectNotFoundException is raised and terminated...
172  this.WaitForMe();
173 
174  //org.openqa.selenium.support.ui.Select
175  Select SelectList = new Select( this.Me() );
176 
177  for ( String lvsValue : fps_Values )
178  {
179  if ( lvsValue.equals( OKW_Const_Sngltn.getInstance().GetOKWConst4Internalname( "DELETE" ) ) )
180  {
181  SelectList.deselectAll();
182  }
183  else
184  {
185  SelectList.selectByVisibleText( lvsValue );
186  }
187  }
188  }
189  finally
190  {
191  this.LogFunctionEndDebug();
192  }
193  }
194 
211  @Override
212  public void SetValue( ArrayList<String> fpsValues )
213  {
214  this.LogFunctionStartDebug( "SetValue", "fpsValues", fpsValues.toString() );
215 
216  try
217  {
218  // Waiting for the object.
219  // If it does not exist after TimeOut
220  // then the exception OKWGUIObjectNotFoundException is raised and terminated...
221  this.WaitForMe();
222 
223  Select SelectList = new Select( this.Me() );
224 
225  // Zunächst alle ausgwählten Werte der Listbox löschen, wenn eine mehrfachauswahl möglich ist...
226  if ( SelectList.isMultiple() )
227  {
228  SelectList.deselectAll();
229  }
230  else
231  {
232  if ( fpsValues.size() > 1 )
233  this.LogError( "ListBox erlaub keine Mehrfachauswahl." );
234  // \todo TODO: Text in XML auslagern.
235  // \todo TODO: Exception für NichtErlaubte Mehrfachauswahl setzen.
236 
237  }
238 
239  // Danach die gegebene Werte auswählen
240  for ( String lvsValue : fpsValues )
241  {
242  SelectList.selectByVisibleText( lvsValue );
243  }
244  }
245  finally
246  {
247  this.LogFunctionEndDebug();
248  }
249  }
250 
262  @Override
263  public ArrayList<String> getValue()
264  {
265  ArrayList<String> lvLsReturn = new ArrayList<String>();
266  Boolean lvbSelectionFound = false;
267 
268  try
269  {
270  this.LogFunctionStartDebug( "GetValue" );
271 
272  // Waiting for the object.
273  // If it does not exist after TimeOut
274  // then the exception OKWGUIObjectNotFoundException is raised and terminated...
275  this.WaitForMe();
276 
277  Select SelectList = new Select( this.Me() );
278 
279  for ( WebElement Option : SelectList.getAllSelectedOptions() )
280  {
281  lvLsReturn.add( Option.getAttribute( "textContent" ) );
282  lvbSelectionFound = true;
283  }
284 
285  if (!lvbSelectionFound) lvLsReturn.add("");
286 
287  }
288  finally
289  {
290  this.LogFunctionEndDebug( lvLsReturn );
291  }
292 
293  return lvLsReturn;
294  }
295 }
okw.gui.OKWLocatorBase
Definition: OKWLocatorBase.java:3
okw.gui.adapter.selenium.SeSelect
Definition: SeSelect.java:141
okw.gui.adapter.selenium.SeAnyChildWindow.WaitForMe
Boolean WaitForMe()
Wartet auf das Objekt Wenn kein Fenster gefunden wird,.
Definition: SeAnyChildWindow.java:1582
okw.gui.AnyWinBase.LogFunctionEndDebug
void LogFunctionEndDebug()
Methode ruft die Methode Logger.Instance.LogFunctionEndDebug() auf.
Definition: AnyWinBase.java:298
okw.gui.adapter.selenium.SeAnyChildWindow
Definition: SeAnyChildWindow.java:74
okw.gui.adapter.selenium.SeSelect.SeSelect
SeSelect(String Locator, OKWLocatorBase... Locators)
Definition: SeSelect.java:147
okw.gui.adapter.selenium.SeSelect.Select
void Select(ArrayList< String > fps_Values)
Methode wählt einen oder mehrere Werte in einer ListBox aus.
Definition: SeSelect.java:163
okw.gui.adapter.selenium.SeSelect.SetValue
void SetValue(ArrayList< String > fpsValues)
Methode setzt einen oder mehrere Werte in einer ListBox.
Definition: SeSelect.java:212
okw.gui.adapter.selenium.SeSelect.getValue
ArrayList< String > getValue()
Holt die aktuell ausgewählten Werte aus der ListBox.
Definition: SeSelect.java:263
okw.OKW_Const_Sngltn.getInstance
static OKW_Const_Sngltn getInstance()
Holt die einzige Instanz dieser Klasse.
Definition: OKW_Const_Sngltn.java:277
okw.OKW_Const_Sngltn
OKW_Const verwaltet die sprachabhängigen OKW-Konstanten.
Definition: OKW_Const_Sngltn.java:127
okw.gui.adapter.selenium.SeAnyChildWindow.Me
WebElement Me()
Ermittelt aus dem gegebenen Locator das DOM-Elelement, welches das Objekt representiert.
Definition: SeAnyChildWindow.java:751
okw.gui.AnyWinBase.LogFunctionStartDebug
void LogFunctionStartDebug(String fpsMethodName)
Methode ruft die Methode Logger.Instance.LogFunctionStartDebug(fps_FunctionName), und erweitert den g...
Definition: AnyWinBase.java:212
okw.OKW_Const_Sngltn.GetOKWConst4Internalname
String GetOKWConst4Internalname(String fpsInternalname)
Methode ermittelt für Internalname und der aktuell eingestellten Sprache den Wert für OKWConst.
Definition: OKW_Const_Sngltn.java:608