OpenKeyWord  Version: 426, Datum:
SeListBox.cs
1 #region Header
2 /*
3  ==============================================================================
4  Author: Zoltan Hrabovszki <zh@openkeyword.de>
5 
6  Copyright © 2012, 2013, 2014, 2015 IT-Beratung Hrabovszki
7  www.OpenKeyWord.de
8  ==============================================================================
9 
10  This file is part of OpenKeyWord.
11 
12  OpenKeyWord is free software: you can redistribute it and/or modify
13  it under the terms of the GNU General Public License as published by
14  the Free Software Foundation, either version 3 of the License, or
15  (at your option) any later version.
16 
17  OpenKeyWord is distributed in the hope that it will be useful,
18  but WITHOUT ANY WARRANTY; without even the implied warranty of
19  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
20  GNU General Public License for more details.
21 
22  You should have received a copy of the GNU General Public License
23  along with OpenKeyWord. If not, see <http://www.gnu.org/licenses/>.
24 
25  Diese Datei ist Teil von OpenKeyWord.
26 
27  OpenKeyWord ist Freie Software: Sie können es unter den Bedingungen
28  der GNU General Public License, wie von der Free Software Foundation,
29  Version 3 der Lizenz oder (nach Ihrer Wahl) jeder späteren
30  veröffentlichten Version, weiterverbreiten und/oder modifizieren.
31 
32  OpenKeyWord wird in der Hoffnung, dass es nützlich sein wird, aber
33  OHNE JEDE GEWÄHRLEISTUNG, bereitgestellt; sogar ohne die implizite
34  Gewährleistung der MARKTFÄHIGKEIT oder EIGNUNG FÜR EINEN BESTIMMTEN ZWECK.
35  Siehe die GNU General Public License für weitere Details.
36 
37  Sie sollten eine Kopie der GNU General Public License zusammen mit
38  OpenKeyWord erhalten haben. Wenn nicht, siehe <http://www.gnu.org/licenses/>.
39 */
40 #endregion Header
41 
42 namespace OKW.GUI.Selenium
43 {
44  using System;
45  using System.Collections.Generic;
46 
47  using OKW.GUI;
48  using OKW.Log;
49 
50  using OpenQA.Selenium;
51  using OpenQA.Selenium.Support.UI;
52 
57  public class SeListBox : SeAnyWin // , IOKW_ListDataObj, I
58  {
59  #region Constructors
60 
67  public SeListBox(string Locator)
68  : base(Locator)
69  {
70  }
71 
81  public virtual void Select(List<string> fps_Values)
82  {
83  this.LogFunctionStartDebug("Select", "fps_Values", fps_Values.ToString());
84 
85  try
86  {
87  // Wenn das Objekt nicht existiert mit Exception beenden...
88  if (!this.GetExists())
89  {
90  string lvsLM = this.LM.GetMessage("Common", "OKWGUIObjectNotFoundException", "Select()");
91  throw new OKWGUIObjectNotFoundException(lvsLM);
92  }
93 
94  //org.openqa.selenium.support.ui.Select
95  SelectElement SelectList = new SelectElement(this.Me());
96 
97  foreach (string lvsValue in fps_Values )
98  {
99  SelectList.SelectByText(lvsValue);
100  }
101  }
102  finally
103  {
104  this.LogFunctionEndDebug();
105  }
106 
107  return;
108  }
109 
125  public virtual void SetValue(List<string> fpsValues)
126  {
127  this.LogFunctionStartDebug("SetValue", "fpsValues", fpsValues.ToString());
128 
129  try
130  {
131  // Wenn das Objekt nicht existiert mit Exception beenden...
132  if (!this.GetExists())
133  {
134  string lvsLM = this.LM.GetMessage("Common", "OKWGUIObjectNotFoundException", "Select()");
135  throw new OKWGUIObjectNotFoundException(lvsLM);
136  }
137 
138  SelectElement SelectList = new SelectElement(this.Me());
139 
140  // Zunächst alle ausgwählten Werte der Listbox löschen, wenn eine mehrfachauswahl möglich ist...
141  if (SelectList.IsMultiple)
142  {
143  SelectList.DeselectAll();
144  }
145  else
146  {
147  if (fpsValues.Count > 1)
148  MyLogger.LogError( "ListBox erlaub keine Mehrfachauswahl." );
149  // \todo TODO: Text in XML auslagern.
150  // \todo TODO: Exception für NichtErlaubte Mehrfachauswahl setzen.
151 
152  }
153 
154  // Danach die gegebene Werte auswählen
155  foreach (string lvsValue in fpsValues )
156  {
157  SelectList.SelectByText(lvsValue);
158  }
159  }
160  finally
161  {
162  this.LogFunctionEndDebug();
163  }
164 
165  return;
166  }
167 
168 
180  public override List<string> GetValue()
181  {
182  List<string> lvLsReturn = new List<string>();
183  bool bOK = false;
184 
185  try
186  {
187  MyLogger.LogFunctionStartDebug("GetValue");
188 
189  SelectElement SelectList = new SelectElement(this.Me());
190 
191  foreach(IWebElement Option in SelectList.AllSelectedOptions)
192  {
193  lvLsReturn.Add( Option.GetAttribute("textContent") );
194  }
195 
196  bOK = true;
197  }
198  finally
199  {
200  if (bOK)
201  {
202  MyLogger.LogFunctionEndDebug(lvLsReturn);
203  }
204  else
205  {
206  MyLogger.LogFunctionEndDebug();
207  }
208  }
209 
210  return lvLsReturn;
211  }
212 
213 
214  #endregion Constructors
215  }
216 }
SeListBox(string Locator)
TODO: Konstruktor des SeListBoxs.
Definition: SeListBox.cs:67
virtual void SetValue(List< string > fpsValues)
Methode setzt einen oder mehrere Werte in einer ListBox.
Definition: SeListBox.cs:125
Diese Ausnahme wird ausgelöst, wenn ein GUI-Objekt zu den im Frame gegebenen Objekterkennungseigensch...
virtual void Select(List< string > fps_Values)
Methode wählt einen oder mehrere Werte in einer ListBox aus.
Definition: SeListBox.cs:81
override List< string > GetValue()
Holt die aktuell ausgewählten Werte aus der ListBox.
Definition: SeListBox.cs:180
SeListBox ist ein Selenium GUI-Objekt. Erbt von SeAnyWin.
Definition: SeListBox.cs:57
Definition: Core.cs:40