42 namespace OKW.GUI.Selenium
45 using System.Collections.Generic;
46 using System.Collections.ObjectModel;
48 using System.Threading;
53 using OpenQA.Selenium;
54 using OpenQA.Selenium.Internal;
68 public static void Highlight(
this IWebElement element)
72 string orig = element.GetAttribute(
"style");
73 SetAttribute(element,
"style",
"color: yellow; border: 1px solid yellow; background-color: black;");
75 SetAttribute(element,
"style",
"color: black; border: 1px solid black; background-color: yellow;");
81 SetAttribute(element,
"style", orig);
84 public static void SetAttribute(
this IWebElement element,
string attributeName,
string value)
86 IWrapsDriver wrappedElement = element as IWrapsDriver;
87 if (wrappedElement == null)
89 throw new ArgumentException(
"element",
"Element must wrap a web driver");
92 IWebDriver driver = wrappedElement.WrappedDriver;
93 IJavaScriptExecutor javascript = driver as IJavaScriptExecutor;
94 if (javascript == null)
96 throw new ArgumentException(
"element",
"Element must wrap a web driver that supports javascript execution");
100 javascript.ExecuteScript(
"arguments[0].setAttribute(arguments[1], arguments[2])", element, attributeName, value);
104 System.Console.WriteLine(
"============================================");
105 System.Console.WriteLine(e.Message);
106 System.Console.WriteLine(
"============================================");
124 protected Log.Logger MyLogger = Log.Logger.Instance;
134 : base(Locator, fpLocators)
138 #endregion Constructors
154 this.LogFunctionStartDebug(
"ClickOn");
157 if (!this.GetExists())
159 string lvsLM = this.LM.
GetMessage(
"Common",
"OKWGUIObjectNotFoundException",
"SeAnyWin.TypeKey()");
167 this.LogFunctionEndDebug();
183 this.MyLogger.LogFunctionStartDebug(
"Exists");
184 bool lvbReturn =
false;
195 this.MyLogger.LogPrintDebug(
"NoSuchElementException");
203 this.MyLogger.LogFunctionEndDebug(lvbReturn);
207 this.MyLogger.LogFunctionEndDebug();
224 bool lvbReturn =
false;
226 var lvDisabled =
string.Empty;
230 this.MyLogger.LogFunctionStartDebug(
"GetIsActive");
233 if (!this.GetExists())
235 string lvsLM = this.LM.
GetMessage(
"Common",
"OKWGUIObjectNotFoundException",
"SeAnyWin.TypeKey()");
239 lvDisabled = this.Me().GetAttribute(
"disabled");
241 if (lvDisabled == null || lvDisabled !=
"true")
256 this.MyLogger.LogFunctionEndDebug(lvbReturn);
260 this.MyLogger.LogFunctionEndDebug();
283 bool lvbReturn =
false;
288 this.MyLogger.LogFunctionStartDebug(
"LogExists");
290 lvbReturn = this.GetExists();
298 this.MyLogger.LogFunctionEndDebug(lvbReturn);
302 this.MyLogger.LogFunctionEndDebug();
325 bool lvbReturn =
false;
330 this.MyLogger.LogFunctionStartDebug(
"LogIsActive");
332 lvbReturn = this.GetIsActive();
340 this.MyLogger.LogFunctionEndDebug(lvbReturn);
344 this.MyLogger.LogFunctionEndDebug();
359 public virtual IWebElement
Me()
361 this.MyLogger.LogFunctionStartDebug(
"Me");
362 IWebElement me = null;
364 ReadOnlyCollection<IWebElement> meme;
374 string lvsPrintMe =
"GUI-Objekt wurde nicht gefunden: Locator: >>" + this.Locator +
"<<";
376 this.MyLogger.LogPrint(
"????????????????????????????????????????????????????????????" );
377 this.MyLogger.LogPrint( lvsPrintMe );
378 this.MyLogger.LogPrint(
"????????????????????????????????????????????????????????????" );
382 else if (meme.Count > 1)
384 string lvsPrintMe =
"Locator ist nicht eindeutig, es wurden mehrer GUI-Objekt gefunden:\n Locator: >>" + this.Locator +
"<<";
386 this.MyLogger.LogPrint(
"????????????????????????????????????????????????????????????" );
387 this.MyLogger.LogPrint( lvsPrintMe );
388 this.MyLogger.LogPrint(
"????????????????????????????????????????????????????????????" );
402 this.MyLogger.LogFunctionEndDebug(me.ToString());
406 this.MyLogger.LogFunctionEndDebug();
430 bool lvbReturn =
false;
434 this.MyLogger.LogFunctionStartDebug(
"MemorizeExists");
436 lvbReturn = this.GetExists();
443 this.MyLogger.LogFunctionEndDebug(lvbReturn);
447 this.MyLogger.LogFunctionEndDebug();
468 bool lvbReturn =
false;
472 this.MyLogger.LogFunctionStartDebug(
"MemorizeIsActive");
474 lvbReturn = this.GetIsActive();
481 this.MyLogger.LogFunctionEndDebug(lvbReturn);
485 this.MyLogger.LogFunctionEndDebug();
506 this.MyLogger.LogFunctionStartDebug(
"Exists");
507 bool lvb_Return =
false;
516 catch (NoSuchElementException)
518 this.MyLogger.LogPrint(
"NoSuchElementException");
526 this.MyLogger.LogFunctionEndDebug(lvb_Return);
530 this.MyLogger.LogFunctionEndDebug();
551 this.LogFunctionStartDebug(
"SetFocus");
556 if (!this.GetExists())
558 string lvsLM = this.LM.
GetMessage(
"Common",
"OKWGUIObjectNotFoundException",
"SetFocus()");
562 this.Me().SendKeys(
string.Empty);
566 this.LogFunctionEndDebug();
582 public virtual void TypeKey(List<string> fps_Values)
586 this.LogFunctionStartDebug(
"TypeKey",
"fps_Values", fps_Values.ToString());
589 if (!this.GetExists())
591 string lvsLM = this.LM.
GetMessage(
"Common",
"OKWGUIObjectNotFoundException",
"SeAnyWin.TypeKey()");
596 IWebElement lv_WebElement = this.Me();
599 foreach (
string lvsValue
in fps_Values)
602 lv_WebElement.SendKeys(lvsValue);
607 this.LogFunctionEndDebug();
634 this.MyLogger.LogFunctionStartDebug(
"VerifyExists",
"fpbExpectedValue", fpbExpectedValue.ToString());
636 bool lvbReturn =
true;
645 lvbReturn = this.MyWait4Value.
Wait4Value(fpbExpectedValue, myCallBack);
647 if (fpbExpectedValue ==
true && lvbReturn != fpbExpectedValue )
649 this.MyLogger.LogPrint(
string.Format(
"Locator: >>{0}<<", this.Locator) );
658 this.MyLogger.LogFunctionEndDebug(lvbReturn);
662 this.MyLogger.LogFunctionEndDebug();
682 this.MyLogger.LogFunctionStartDebug(
"VerifyIsActive",
"fpbExpectedValue", fpbExpectedValue.ToString());
684 bool lvbReturn =
true;
693 lvbReturn = this.MyWait4Value.
Wait4Value(fpbExpectedValue, myCallBack);
701 this.MyLogger.LogFunctionEndDebug(lvbReturn);
705 this.MyLogger.LogFunctionEndDebug();
728 MyLogger.LogFunctionStartDebug(
"VerifyTooltip",
"fplsExpectedValue", fplsExpectedValue[0]);
730 List<string> lvLsReturn =
new List<string>();
739 lvLsReturn = MyWait4Value.
Wait4Value(fplsExpectedValue, myCallBack);
747 MyLogger.LogFunctionEndDebug(lvLsReturn);
751 MyLogger.LogFunctionEndDebug();
776 public virtual List<string>
VerifyLabel(List<string> fplsExpectedValue)
778 MyLogger.LogFunctionStartDebug(
"VerifyLabel",
"fplsExpectedValue", fplsExpectedValue[0]);
780 List<string> lvLsReturn =
new List<string>();
789 lvLsReturn = MyWait4Value.
Wait4Value(fplsExpectedValue, myCallBack);
797 MyLogger.LogFunctionEndDebug(lvLsReturn);
801 MyLogger.LogFunctionEndDebug();
822 List<string> lvLsReturn =
new List<string>();
826 MyLogger.LogFunctionStartDebug(
"GetTooltip");
829 if (!this.GetExists())
831 string lvsLM = this.LM.
GetMessage(
"Common",
"OKWGUIObjectNotFoundException",
"GetTooltip()");
836 lvLsReturn.Add(this.Me().GetAttribute(
"title"));
843 MyLogger.LogFunctionEndDebug(lvLsReturn);
847 MyLogger.LogFunctionEndDebug();
868 List<string> lvLsReturn =
new List<string>();
872 MyLogger.LogFunctionStartDebug(
"GetTooltip");
875 if (!this.GetExists())
877 string lvsLM = this.LM.
GetMessage(
"Common",
"OKWGUIObjectNotFoundException",
"GetTooltip()");
882 string lvsID = this.Me().GetAttribute(
"id");
885 IWebElement label =
SeDriver.
Instance.driver.FindElement(By.XPath(
"//label[@for='" + lvsID +
"']" ));
886 lvLsReturn.Add(label.GetAttribute(
"textContent"));
893 MyLogger.LogFunctionEndDebug(lvLsReturn);
897 MyLogger.LogFunctionEndDebug();
920 List<string> lvLsReturn =
new List<string>();
925 MyLogger.LogFunctionStartDebug(
"LogTooltip");
927 lvLsReturn = this.GetTooltip();
935 MyLogger.LogFunctionEndDebug(lvLsReturn);
939 MyLogger.LogFunctionEndDebug();
962 List<string> lvLsReturn =
new List<string>();
967 MyLogger.LogFunctionStartDebug(
"LogLabel");
969 lvLsReturn = this.GetLabel();
977 MyLogger.LogFunctionEndDebug(lvLsReturn);
981 MyLogger.LogFunctionEndDebug();
1005 List<string> lvLsReturn = null;
1009 MyLogger.LogFunctionStartDebug(
"MemorizeTooltip");
1011 lvLsReturn = this.GetTooltip();
1018 MyLogger.LogFunctionEndDebug(lvLsReturn);
1022 MyLogger.LogFunctionEndDebug();
1046 List<string> lvLsReturn = null;
1050 MyLogger.LogFunctionStartDebug(
"MemorizeLabel");
1052 lvLsReturn = this.GetLabel();
1059 MyLogger.LogFunctionEndDebug(lvLsReturn);
1063 MyLogger.LogFunctionEndDebug();
1081 bool lvbReturn =
false;
1086 this.LogFunctionStartDebug(
"GetHasFocus");
1089 if (!this.GetExists())
1091 string lvsLM = this.LM.
GetMessage(
"Common",
"OKWGUIObjectNotFoundException",
"GetTooltip()");
1095 IWebElement currentElement =
SeDriver.
Instance.driver.SwitchTo().ActiveElement();
1097 lvbReturn = currentElement.Equals(this.Me());
1104 MyLogger.LogFunctionEndDebug(lvbReturn);
1108 MyLogger.LogFunctionEndDebug();
1127 bool lvbReturn =
false;
1132 this.LogFunctionStartDebug(
"LogHasFocus");
1134 lvbReturn = this.GetHasFocus();
1141 MyLogger.LogFunctionEndDebug(lvbReturn);
1145 MyLogger.LogFunctionEndDebug();
1167 bool lvbReturn =
false;
1172 this.LogFunctionStartDebug(
"MemorizeHasFocus");
1174 lvbReturn = this.GetHasFocus();
1181 MyLogger.LogFunctionEndDebug(lvbReturn);
1185 MyLogger.LogFunctionEndDebug();
1204 bool lvbReturn =
false;
1209 MyLogger.LogFunctionStartDebug(
"VerifyHasFocus",
"fpbExpectedValue", fpbExpectedValue.ToString());
1215 lvbReturn = MyWait4Value.
Wait4Value(fpbExpectedValue, myCallBack);
1222 MyLogger.LogFunctionEndDebug(lvbReturn);
1226 MyLogger.LogFunctionEndDebug();
1249 MyLogger.LogFunctionStartDebug(
"VerifyCaption",
"fplsExpectedValue", fplsExpectedValue[0]);
1251 List<string> lvLsReturn =
new List<string>();
1260 lvLsReturn = MyWait4Value.
Wait4Value(fplsExpectedValue, myCallBack);
1268 MyLogger.LogFunctionEndDebug(lvLsReturn);
1272 MyLogger.LogFunctionEndDebug();
1295 List<string> lvLsReturn =
new List<string>();
1300 MyLogger.LogFunctionStartDebug(
"LogCaption");
1302 lvLsReturn = this.GetCaption();
1310 MyLogger.LogFunctionEndDebug(lvLsReturn);
1314 MyLogger.LogFunctionEndDebug();
1338 List<string> lvLsReturn = null;
1342 MyLogger.LogFunctionStartDebug(
"MemorizeCaption");
1344 lvLsReturn = this.GetCaption();
1351 MyLogger.LogFunctionEndDebug(lvLsReturn);
1355 MyLogger.LogFunctionEndDebug();
1375 List<string> lvLsReturn =
new List<string>();
1379 MyLogger.LogFunctionStartDebug(
"GetCaption");
1382 if (!this.GetExists())
1384 string lvsLM = this.LM.
GetMessage(
"Common",
"OKWGUIObjectNotFoundException",
"GetCaption()");
1389 lvLsReturn.Add(this.Me().GetAttribute(
"textContent"));
1396 MyLogger.LogFunctionEndDebug(lvLsReturn);
1400 MyLogger.LogFunctionEndDebug();
1415 List<string> lvLsReturn =
new List<string>();
1420 this.LogFunctionStartDebug(
"GetValue");
1423 lvLsReturn.Add(this.Me().GetAttribute(
"textContent"));
1430 this.LogFunctionEndDebug(lvLsReturn.ToString());
1434 this.LogFunctionEndDebug();
1454 List<string> lvLsReturn =
new List<string>();
1458 MyLogger.LogFunctionStartDebug(
"LogValue");
1459 lvLsReturn = this.GetValue();
1466 MyLogger.LogFunctionEndDebug(lvLsReturn);
1470 MyLogger.LogFunctionEndDebug();
1493 List<string> lvLsReturn =
new List<string>();
1498 MyLogger.LogFunctionStartDebug(
"Memorize");
1499 lvLsReturn = this.GetValue();
1506 MyLogger.LogFunctionEndDebug(lvLsReturn);
1510 MyLogger.LogFunctionEndDebug();
1528 public virtual List<string>
VerifyValue(List<string> fplsExpectedValue)
1530 List<string> lvLsReturn =
new List<string>();
1535 MyLogger.LogFunctionStartDebug(
"Memorize",
"fplsExpectedValue", fplsExpectedValue[0]);
1541 lvLsReturn = MyWait4Value.
Wait4Value(fplsExpectedValue, myCallBack);
1549 MyLogger.LogFunctionEndDebug(lvLsReturn);
1553 MyLogger.LogFunctionEndDebug();
virtual void SetFocus()
Setzt den Focus auf das Objekt. Anmerkung: Kleiner Trick: Selenium kennt keine öffentliche c#-Methode...
virtual List< string > LogCaption()
Ermittelt den textuellen Inhalt der Beschriftung (Caption).
string GetMessage(string MethodName, string TextKey)
Holt die Log-Meldung für MethodeNmae/Textkey ohne weitere Parameter.
virtual bool VerifyHasFocus(bool fpbExpectedValue)
Ermittelt den textuellen Inhalt des ToolTips.
static SeDriver Instance
Gibt die Instance für die einzige Instanz dieser Klasse zurück. Hinweis:
virtual List< string > VerifyLabel(List< string > fplsExpectedValue)
Ermittelt den textuellen Inhalt des Labels für Prüfewert.
virtual bool MemorizeExists()
Ermittelt ob das Atuelle Objekt existiert, für das Schlüsselwort MerkeVorhanden.
virtual List< string > GetLabel()
Ermittelt den textuellen Inhalt des Labels.
virtual List< string > MemorizeTooltip()
Ermittelt den textuellen Inhalt des ToolTips für das Schlüsselwort MerkeWert.
delegate List< string > ListStringCallBack()
Callback Muster string Variante.
virtual List< string > LogValue()
Ermittelt den Wert des Objktes für das Schlüsselwort Loggewert.
virtual bool MemorizeIsActive()
Ermittelt für das Schlüsselwort MerkeIstAktive, ob das aktuelle Objekt aktiv ist. ...
Diese Ausnahme wird ausgelöst, wenn ein GUI-Objekt zu den im Frame gegebenen Objekterkennungseigensch...
Erweiterung des IWebelemets.
virtual List< string > MemorizeLabel()
Ermittelt den textuellen Inhalt des Labels für das Schlüsselwort MerkeWert.
virtual bool NotExists()
Prüft die nicht Existenz des aktuellen Objektes. Anmerkung: Falls ein Objekt zunächst noch vorhand is...
virtual bool VerifyIsActive(bool fpbExpectedValue)
Ermittelt/Prüft, ob das aktuelle Objekt aktiv ist.
virtual bool GetHasFocus()
Methode liefert den aktuellen Zustand Wert des Focus. Quelle: http://stackoverflow.com/questions/7491806/in-selenium-how-do-i-find-the-current-object.
virtual List< string > GetValue()
Holt den aktuellen Text aus einem HTML-Tag.
virtual List< string > LogTooltip()
Logt den textuellen Inhalt des ToolTips.
virtual bool MemorizeHasFocus()
Ermittelt ob das Objekt den Fokus besitz und liefert diesen für das Schlüsselwort MerkeWert...
virtual bool LogExists()
Ermittelt den textuellen Inhalt des ToolTips.
virtual List< string > VerifyTooltip(List< string > fplsExpectedValue)
Ermittelt den textuellen Inhalt des ToolTips für Prüfewert.
OKW_Wait4Value ist die zetrale Klasse, die für das Warten auf GUI eigenschaften zuständig ist...
virtual List< string > GetCaption()
Ermittelt den textuellen Inhalt der Caption/Überschrift des Objektes.
virtual bool LogIsActive()
Ermittelt, ob das aktuelle Objket Aktiv ist.
string Wait4Value(string fpExpected, StringCallBack fpCallMeBack)
Methode liest den Wert aus der deligierten Methode fpCallMeBack wartet ggf. und liefert den Wert zurü...
virtual List< string > MemorizeValue()
Ermittelt den Wert, im Allgemeinen den textuellen Inhalt eines Objektes für das Schlüsselwort MerkeWe...
virtual IWebElement Me()
Ermittelt aus dem gegebenen Locator das DOM-Elelement, welches das Objekt representiert.
virtual List< string > LogLabel()
Logt den textuellen Inhalt des Labels eines Objektes.
delegate bool BoolCallBack()
Callback Muster string Variante.
LogMessenger liest Log-Meldungen sprachspezifisch für die im Konstruktor gegeben Klasse aus der Zugeh...
void LogPrintDebug(string fpsMessage)
Loggt eine Nachricht.
virtual bool GetIsActive()
Prüft, ob das aktuellen Objekt aktiv ist.
virtual bool GetExists()
Prüft die Existenz des Aktuellen Objektes.
Description of OKWLocator.
virtual void ClickOn()
Klickt auf das aktuelle Objekt.
virtual List< string > VerifyCaption(List< string > fplsExpectedValue)
Ermittelt den textuellen Inhalt des ToolTips für Prüfewert.
virtual bool VerifyExists(bool fpbExpectedValue)
Ermittelt/Prüft, ob das aktuelle Objekt existiert.
virtual List< string > GetTooltip()
Ermittelt den textuellen Inhalt des ToolTips.
virtual List< string > VerifyValue(List< string > fplsExpectedValue)
Ermittelt den textuellen Inhalt des markierten Textes für Prüfewert.
virtual List< string > MemorizeCaption()
Ermittelt den textuellen Inhalt des Caption/Überschrift für das Schlüsselwort MerkeWert.
virtual bool LogHasFocus()
Ermittelt für LoggeWert, ob das aktuelle Objekt den Fokus hat.
virtual void TypeKey(List< string > fps_Values)
Tastatur Eingabe an das Objekt.