OpenKeyWord  Build_ID: 457, Datum: 01.02.2020 07:45:48
Dont repeat yourself. - Do it once and only once!
myTextfield.java
1 /*
2  ==============================================================================
3  Author: Zoltán Hrabovszki <zh@openkeyword.de>
4 
5  Copyright © 2012 - 2019 IT-Beratung Hrabovszki
6  www.OpenKeyWord.de
7  ==============================================================================
8 
9  This file is part of OpenKeyWord.
10 
11  OpenKeyWord is free software: you can redistribute it and/or modify
12  it under the terms of the GNU General Public License as published by
13  the Free Software Foundation, either version 3 of the License, or
14  (at your option) any later version.
15 
16  OpenKeyWord is distributed in the hope that it will be useful,
17  but WITHOUT ANY WARRANTY; without even the implied warranty of
18  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
19  GNU General Public License for more details.
20 
21  You should have received a copy of the GNU General Public License
22  along with OpenKeyWord. If not, see <http://www.gnu.org/licenses/>.
23 
24  Diese Datei ist Teil von OpenKeyWord.
25 
26  OpenKeyWord ist Freie Software: Sie können es unter den Bedingungen
27  der GNU General Public License, wie von der Free Software Foundation,
28  Version 3 der Lizenz oder (nach Ihrer Wahl) jeder späteren
29  veröffentlichten Version, weiterverbreiten und/oder modifizieren.
30 
31  OpenKeyWord wird in der Hoffnung, dass es nützlich sein wird, aber
32  OHNE JEDE GEWÄHRLEISTUNG, bereitgestellt; sogar ohne die implizite
33  Gewährleistung der MARKTFÄHIGKEIT oder EIGNUNG FÜR EINEN BESTIMMTEN ZWECK.
34  Siehe die GNU General Public License für weitere Details.
35 
36  Sie sollten eine Kopie der GNU General Public License zusammen mit
37  OpenKeyWord erhalten haben. Wenn nicht, siehe <http://www.gnu.org/licenses/>.
38 */
39 
40 package okw.gui.adapter;
41 
42 import java.util.ArrayList;
43 
44 import org.openqa.selenium.JavascriptExecutor;
45 import org.openqa.selenium.WebElement;
46 
47 import okw.gui.OKWLocatorBase;
48 import okw.gui.adapter.selenium.SeInputText;
49 import okw.gui.adapter.selenium.webdriver.SeDriver;
50 
117 public class myTextfield extends SeInputText
118 {
119 
123  public myTextfield( String Locator, OKWLocatorBase... Locators )
124  {
125  super( Locator, Locators );
126  }
127 
128 
141  @Override
142  public ArrayList<String> getCaption()
143  {
144  return getValue();
145  }
146 
147 
159  public Integer getMaxLength()
160  {
161  Integer lviReturn = 0;
162 
163  try
164  {
165  this.LogFunctionStartDebug( "getMaxLength" );
166 
167  // Warten auf das Objekt. Wenn es nicht existiert wird mit OKWGUIObjectNotFoundException beendet...
168  this.WaitForMe();
169 
170 
171  // The Attribute "MaxLength" auslesen...
172 
173  String lvsMaxLength = this.Me().getAttribute( "maxlength" );
174 
175  if ( !okw.OKW_Helper.isStringNullOrEmpty( lvsMaxLength) )
176  {
177  lviReturn = Integer.parseInt( lvsMaxLength );
178  }
179  }
180  finally
181  {
182  this.LogFunctionEndDebug( lviReturn.toString() );
183  }
184 
185  return lviReturn;
186  }
187 
188 
206  public ArrayList<String> getPlaceholder()
207  {
208  ArrayList<String> lvLsReturn = new ArrayList<String>();
209 
210  try
211  {
212  this.LogFunctionStartDebug( "getPlaceholder" );
213 
214  // Warten auf das Objekt. Wenn es nicht existiert wird mit OKWGUIObjectNotFoundException beendet...
215  this.WaitForMe();
216 
217  // Get Value from TextField and put this into the return ArrayList<String>
218  lvLsReturn.add( this.Me().getAttribute( "placeholder" ) );
219  }
220  finally
221  {
222  this.LogFunctionEndDebug( lvLsReturn );
223  }
224 
225  return lvLsReturn;
226  }
227 
228 
240  @Override
241  public ArrayList<String> getValue()
242  {
243  ArrayList<String> lvLsReturn = new ArrayList<String>();
244 
245  try
246  {
247  this.LogFunctionStartDebug( "GetValue" );
248 
249  // Warten auf das Objekt. Wenn es nicht existiert wird mit OKWGUIObjectNotFoundException beendet...
250  this.WaitForMe();
251 
252  // Get Value from TextField and put this into the return List<string>
253  String myValue = this.Me().getAttribute( "value" );
254 
255  if ( myValue != null )
256  {
257  lvLsReturn.add( this.Me().getAttribute( "value" ) );
258  }
259 
260  }
261  finally
262  {
263  this.LogFunctionEndDebug( lvLsReturn.toString() );
264  }
265 
266  return lvLsReturn;
267  }
268 
269 
270  public void set__Attribute( WebElement elem, String value )
271  {
272  JavascriptExecutor js = ( JavascriptExecutor ) SeDriver.getInstance().getDriver();
273 
274  String scriptSetAttrValue = "arguments[0].setAttribute(arguments[1],arguments[2])";
275 
276  js.executeScript( scriptSetAttrValue, elem, "value", value );
277 
278  }
279 
283  @Override
284  public void SetValue( ArrayList<String> Val )
285  {
286 
287  try
288  {
289  this.LogFunctionStartDebug( "SetValue", "Val", Val.toString() );
290 
291  // Wenn GUI-Objekt nicht gefunden wird, mit OKWGUIObjectNotFoundException aussteigen
292  this.WaitForMe();
293 
294  WebElement myMe = this.Me();
295  myMe.clear();
296 
297  if ( Val.get( 0 ).equals( okw.OKW_Const_Sngltn.getInstance().GetOKWConst4Internalname( "DELETE" ) ) )
298  {
299  myMe.clear();
300  }
301  else
302  {
303  myMe.sendKeys( Val.get( 0 ) );
304  }
305  }
306  finally
307  {
308  this.LogFunctionEndDebug();
309  }
310  }
311 
312 }
okw.gui.OKWLocatorBase
Definition: OKWLocatorBase.java:3
okw.gui.adapter.selenium.SeAnyChildWindow.WaitForMe
Boolean WaitForMe()
Wartet auf das Objekt Wenn kein Fenster gefunden wird,.
Definition: SeAnyChildWindow.java:1582
okw.gui.adapter.selenium.webdriver.SeDriver
Pattern Singelton.
Definition: SeDriver.java:60
okw.gui.adapter.myTextfield
Definition: myTextfield.java:117
okw.gui.AnyWinBase.LogFunctionEndDebug
void LogFunctionEndDebug()
Methode ruft die Methode Logger.Instance.LogFunctionEndDebug() auf.
Definition: AnyWinBase.java:298
okw.gui.adapter.myTextfield.getPlaceholder
ArrayList< String > getPlaceholder()
Liest den Placeholder des input-Tags aus.
Definition: myTextfield.java:206
okw.gui.adapter.myTextfield.getValue
ArrayList< String > getValue()
Ermittelt den Wert des Textfeldes, welches dem sichtbaren .
Definition: myTextfield.java:241
okw.gui.adapter.selenium.webdriver.SeDriver.getInstance
static SeDriver getInstance()
Gibt die Instance für die einzige Instanz dieser Klasse zurück.
Definition: SeDriver.java:102
okw.gui.adapter.myTextfield.myTextfield
myTextfield(String Locator, OKWLocatorBase... Locators)
Definition: myTextfield.java:123
okw.gui.adapter.selenium.SeInputText
Definition: SeInputText.java:114
okw.gui.adapter.myTextfield.getCaption
ArrayList< String > getCaption()
Ermittelt den textuellen Inhalt der Überschrift eines Textfeldes.
Definition: myTextfield.java:142
okw.gui.adapter.myTextfield.SetValue
void SetValue(ArrayList< String > Val)
Definition: myTextfield.java:284
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.gui.adapter.myTextfield.getMaxLength
Integer getMaxLength()
Ermittelt den textuellen Inhalt des Labels.
Definition: myTextfield.java:159