/// <summary> /// Searches all elements for the an element that matches the provided value. /// /// The value returned is the first match, and the search order is: /// - Html Tag name /// - id attribute /// - innerHtml /// </summary> /// <param name="watinIe"></param> /// <param name="value"></param> /// <returns></returns> public static Element element(this WatiN_IE watinIe, string value) { if (watinIe.isNull() || value.notValid()) { return(null); } var element_by_Tag = watinIe.elements().with_TagName(value); if (element_by_Tag.notNull()) { return(element_by_Tag); } var element_by_Id = watinIe.elements().with_Id(value); if (element_by_Id.notNull()) { return(element_by_Id); } var element_by_InnerText = watinIe.elements().with_InnerText(value); if (element_by_InnerText.notNull()) { return(element_by_InnerText); } return(null); }
public static DialogWatcher getDialogWatcher(this WatiN_IE watinIe) { if (watinIe.isNull() || watinIe.IE.isNull()) { return(null); } watinIe.setDialogWatcher(); return(watinIe.IE.DialogWatcher); }
public static WatiN_IE add_NavigationBar(this WatiN_IE watinIe, Control control) { if (watinIe.isNull()) { return(watinIe); } var urlTextBox = control.insert_Above(20) .add_TextBox("Url:", "") .onEnter((text) => watinIe.open_ASync(text)); watinIe.onNavigate((url) => urlTextBox.set_Text(url)); return(watinIe); }
public static WatiN_IE open(this WatiN_IE watinIe, string url, int miliseconds) { if (watinIe.isNull()) { return(watinIe); } "[WatIN] open: {0}".info(url); watinIe.execute( () => { watinIe.IE.GoTo(url); watinIe.wait(miliseconds); }); return(watinIe); }
public static WatiN_IE setDialogWatcher(this WatiN_IE watinIe) { if (watinIe.isNull()) { return(null); } if (watinIe.IE.DialogWatcher == null) { //set the value of IE.DialogWatcher with the current inproc IE dialogWatcher var dialogWatcher = DialogWatcher.GetDialogWatcher(Processes.getCurrentProcess().MainWindowHandle); var property = PublicDI.reflection.getPropertyInfo("DialogWatcher", typeof(DomContainer)); PublicDI.reflection.setProperty(property, watinIe.IE, dialogWatcher); dialogWatcher.CloseUnhandledDialogs = false; } return(watinIe); }
public static WatiN_IE show_Formated_Javascript(this WatiN_IE ie, WatiN_IE temp_ie, string codeToFormat) { var prettifyHtml = @"prettify.htm".local(); if (prettifyHtml.fileExists().isFalse()) { return(ie); } if (ie.url().isNull() || ie.url().contains("prettify.htm").isFalse()) { ie.open(prettifyHtml); } var formatedJsCode = (temp_ie.isNull()) ? ie.HostControl.formatJsCode(codeToFormat) : temp_ie.formatJsCode(codeToFormat); var codeDiv = ie.div("codeDiv"); codeDiv.innerHtml("<pre id=\"code\" class=\"prettyprint\">{0}</pre>".format(formatedJsCode)); ie.invokeScript("prettyPrint"); return(ie); }