public bool SearchAndSelect() { while (true) { base.Detect(); if (!isMatch) { if (totalPage > currentPage && inputPageNo != null && jumpButton != null) { currentPage++; IHTMLInputElement element = inputPageNo.DomElement as IHTMLInputElement; element.value = currentPage.ToString(); IHTMLElement button = jumpButton.DomElement as IHTMLElement; ((IHTMLElement2)button).focus(); button.click(); } else { break; } } else { break; } } return(isMatch); }
public void OnDocumentComplete(object pDisp, ref object URL) { string notFound = "Sytem.Web.Http.Results.NotFoundResult"; LoginInfo lI = new LoginInfo(); string bongo = lI.password; HTMLDocument document = (HTMLDocument)webBrowser.Document; IHTMLInputElement userName = (IHTMLInputElement)document.getElementById("user"); userName.defaultValue = bongo; IHTMLInputElement password = (IHTMLInputElement)document.getElementById("password"); password.defaultValue = "Syntel-123"; //var links = document.getElementsByTagName("a"); //foreach (IHTMLElement link in links) //{ // if (link.getAttribute("className") == "link_btnPrimary" && link.innerText == "Login") // { // link.click(); // } //} //Boolean answer = lC.matchUrls(urlLink); //if (answer == true) //{ //System.Windows.Forms.MessageBox.Show("They Match!!"); //} }
protected override void PastePaymentInfo(PaymentRequest request) { HTMLDocument doc = request.Document; PaymentInfo info = request.PaymentInfo; if (info.IsDefinedTransfer == false) { IEnumerator e = doc.getElementsByTagName("input").GetEnumerator(); while (e.MoveNext()) { IHTMLInputElement input = e.Current as IHTMLInputElement; if ("AccountNumberFullDestinationInput".Equals((e.Current as IHTMLInputElement).value)) { (e.Current as IHTMLElement).click(); break; } } Util.SetElementValue(doc.getElementById(ACCOUNT_FIELD), info.BankAccountNo); Util.SetElementValue(doc.getElementById(NAME_FIELD), ReplaceSpecialChars(info.BillerName)); Util.SetElementValue(doc.getElementById(ADDRESS_FIELD), ReplaceSpecialChars(info.Street)); Util.SetElementValue(doc.getElementById(POSTAL_CODE_FIELD), ReplaceSpecialChars(info.PostalCodeAndCity)); } Util.SetElementValue(doc.getElementById(DESCRIPTION_FIELD), ReplaceSpecialChars(info.Title)); Util.SetElementValue(doc.getElementsByName(AMOUNT_INT_FIELD), info.AmountToPayDecimal); Util.SetElementValue(doc.getElementsByName(AMOUNT_DEC_FIELD), info.AmountToPayFloating); // real value is taken from hidden field Util.SetElementValue(doc.getElementById(AMOUNT_FIELD), info.AmountToPay.Replace(".", ",")); Util.SetElementValue(doc.getElementsByName(YEAR_FIELD), info.DueDateTimeToPaste.Year.ToString()); Util.SetElementValue(doc.getElementsByName(MONTH_FIELD), Util.GetMonth(info.DueDateTimeToPaste.Month)); Util.SetElementValue(doc.getElementsByName(DAY_FIELD), info.DueDateTimeToPaste.Day.ToString()); info.State = State.IN_PROGRESS; }
private void HookIntroPage() { try { IWebBrowser2 nativeBrowser = (SHDocVw.IWebBrowser2)webBrowser.ActiveXInstance; IHTMLDocument3 introDoc = nativeBrowser.Document as IHTMLDocument3; if (introDoc != null) { introDoc.attachEvent("onclick", new HtmlHandler(this.OnIntroClick, ((IHTMLDocument2)introDoc).parentWindow)); // Initialize checkbox with value in registry. IHTMLInputElement checkBox = (IHTMLInputElement)introDoc.getElementById(CatStudioConstants.INTRO_DONT_ASK_AGAIN_ATTR); RegistryKey twbstStudioRegKey = Registry.CurrentUser.OpenSubKey("Software\\Codecentrix\\OpenTwebst\\Studio", false); if (twbstStudioRegKey != null) { int dontShowIntro = (int)twbstStudioRegKey.GetValue("dontshowintro", 0); checkBox.@checked = (dontShowIntro != 0); twbstStudioRegKey.Close(); } } } catch { // Do nothing. Maybe not this critical. } }
/// <summary> /// Adds a typing action to the action list /// </summary> /// <param name="windowName">window where it was performed</param> /// <param name="activeElement">element the click was performed on</param> /// <param name="url">current url for action</param> /// <returns>action created (mainly for testing)</returns> public ActionTypeText AddText(string windowName, IHTMLInputElement activeElement, string url) { var action = new ActionTypeText(_browsers[windowName], (IHTMLElement)activeElement, url); AddAction(action); return(action); }
protected virtual void FillTextElement(IHTMLElement element, string value) { switch (element.tagName) { case "INPUT": IHTMLInputElement textElement = element as IHTMLInputElement; if (string.IsNullOrEmpty(textElement.value)) { textElement.value = value; this.InvokeOnChange(element); this.FillRecords[(int)ElementType.Text].RecordCount++; } break; case "TEXTAREA": IHTMLTextAreaElement textAreaElement = element as IHTMLTextAreaElement; if (string.IsNullOrEmpty(textAreaElement.value)) { textAreaElement.value = value; this.InvokeOnChange(element); this.FillRecords[(int)ElementType.Text].RecordCount++; } break; } }
/// <summary> /// When the button is clicked, it will execute the Exec method of the /// IOleCommandTarget interface. /// </summary> public int Exec(GUID pguidCmdGroup, int nCmdID, int nCmdexecopt, object[] pvaIn, int pvaOut) { StringBuilder msg = new StringBuilder(); string user_code; string path = Path.GetTempPath() + "merlin.txt"; using (StreamReader sr = File.OpenText(path)) { user_code = sr.ReadLine(); } mshtml.HTMLDocument doc = ieInstance.Document as mshtml.HTMLDocument; IHTMLElementCollection head_collect = doc.all.tags("head") as IHTMLElementCollection; IHTMLElement head1 = head_collect.item(null, 0) as IHTMLElement; IHTMLScriptElement script_Element = doc.createElement("script") as IHTMLScriptElement; script_Element.type = "text/javascript"; script_Element.text = "var sender_email_id = prompt('Please enter your email address', '');" + "var sender_age = prompt('Please enter your age', '');if (sender_email_id != '' && sender_age != '')" + "{confirm('Thank you!');var mesg = 'age_group: ' + sender_age + ' ' + 'email_id: ' + sender_email_id;document.getElementById('age_email').value=mesg}"; string asp = "<input type='hidden' id='age_email' value=''>"; doc.body.insertAdjacentHTML("afterBegin", asp); ((HTMLHeadElement)head1).appendChild((IHTMLDOMNode)script_Element); var mesg = doc.getElementById("age_email"); IHTMLInputElement mesgElement = mesg as IHTMLInputElement; send_data = mesgElement.value + ' ' + user_code; websocket = new WebSocket("ws://merlin.ece.ufl.edu:8080/events/"); websocket.Opened += new EventHandler(websocket_Opened); websocket.Open(); return(0); }
public static string ByInputButton(IHTMLElement element) { IHTMLInputElement input = element as IHTMLInputElement; if (null == input) { return(string.Empty); } string type = input.type.ToLower(); if ("button" != type && "submit" != type && "reset" != type) { return(string.Empty); } string s = input.value; if (string.IsNullOrWhiteSpace(s)) { return(string.Empty); } return(string.Format("button={0}", s)); }
private FormObjectCollection BuildFormsCollection() { FormObjectCollection objects = new FormObjectCollection(); this.EnsureHtmlParser(); foreach (IHTMLFormElement element in this._parsedHtml.forms) { string elementId = this.GetElementId(element as IHTMLElement); if (elementId == null) { elementId = element.name; } FormObject item = new FormObject(elementId, element.method, element.action); foreach (IHTMLElement element2 in element) { IHTMLInputElement element3 = element2 as IHTMLInputElement; if (element3 != null) { elementId = this.GetElementId(element3 as IHTMLElement); if (elementId == null) { elementId = element3.name; } item.AddField(elementId, element3.value); } } objects.Add(item); } return(objects); }
public void ExplicitFormIdSpecified() { CQ cq = CQ.Create("<form id=a><div><input form=b></div></form><form id=b></form>"); IHTMLInputElement input = cq["input"].FirstElement() as IHTMLInputElement; Assert.IsNotNull(input); Assert.IsNotNull(input.Form); Assert.AreEqual("b", input.Form.Id); }
public void ClosestForm() { CQ cq = CQ.Create("<form id=parent><div><input></div></form>"); IHTMLInputElement input = cq["input"].FirstElement() as IHTMLInputElement; Assert.IsNotNull(input); Assert.IsNotNull(input.Form); Assert.AreEqual("parent", input.Form.Id); }
public static void FillText(HTMLDocument document, string id, string value) { IHTMLInputElement element = (IHTMLInputElement)document.getElementById(id); if (null != element) { element.value = null == value ? "" : value; } }
private void DoInputButtonClick(object sender, IHTMLEventObj evt) { IHTMLElement element = evt.srcElement; IHTMLInputElement input = element as IHTMLInputElement; string locator = LocateDetector.Detect(element); string value = IE.Element.GetValue(element); this.OnCommandRecording("click", locator); }
public void setFileField(String fieldId, String filePath) { IHTMLInputElement fileInputField = (IHTMLInputElement)document.getElementById(fieldId); // TODO - Do more checking to verify SetForegroundWindow worked, // and complain if it doesn't. Win32.SetForegroundWindow(webBrowser.HWND); fileInputField.select(); System.Windows.Forms.SendKeys.SendWait(filePath); }
protected override bool OnButtonElementFinded(System.Windows.Forms.HtmlElement buttonElement, Stack <KeyValuePair <System.Windows.Forms.HtmlElement, string> > textNode) { IHTMLInputElement element = buttonElement.DomElement as IHTMLInputElement; if (element.value == "跳转") { jumpButton = buttonElement; } return(!isMatch); }
private bool CompareAgainstInputTypes(IHTMLElement element) { IHTMLInputElement inputElement = (IHTMLInputElement)element; string inputElementType = inputElement.type.ToLower(); if (InputTypes.IndexOf(inputElementType) >= 0) { return(true); } return(false); }
protected override void OnDocumentComplete(object sender, EventArgs args) { Method <string> .Watch("search match", () => { NLResult result = NatualLinkCreator.Instance.Create(this.hostBrowser.GetText(true), LinkStyle.Standard); CreateMatchAnchors(result.MatchWords); if (result.MatchWords.Count > 0) { IHTMLInputElement searchInput = browser.GetElementByID(true, "keyword") as IHTMLInputElement; searchInput.value = result.MatchWords[0]; } }); }
private void login__Click(object sender, EventArgs e) { IHTMLDocument2 doc = (IHTMLDocument2)wb_.Document.DomDocument; IHTMLWindow2 frameEle = doc.frames.item("SI2_mem_index"); IHTMLInputElement accEle = frameEle.document.body.all.item("username"); IHTMLInputElement pwdEle = frameEle.document.body.all.item("password"); var info = GetRegInfo(); accEle.value = info["username"]; pwdEle.value = info["password"]; frameEle.execScript("do_login();"); }
private void HandleSpecialPage() { int formIndex = -1; bool replace = false; for (int i = 0; i < _parameters.Count; i++) { KeyValuePair <FillParameterKey, object> item = _parameters[i]; FillParameter parameter = item.Value as FillParameter; if (parameter != null) { if (item.Key.Key == mainVehicleModel) { // 若当前参数为国五轻型汽油车的主车型型号参数,且网页中的主车型型号不为空,则对其动力系进行编辑操作 // 否则,按正常填报规则执行。 IHTMLInputElement element = GetElement(parameter, formIndex) as IHTMLInputElement; if (element != null && string.IsNullOrEmpty(element.value) == false) { replace = true; } else { return; } } if (item.Key.Type == Matcher.TYPE_FORM) { formIndex++; if (replace && (parameter.Name == formName || parameter.Id == formName)) { if (_parameters.Count <= i + 1) { return; } item = _parameters[i + 1]; parameter = item.Value as FillParameter; if (parameter == null) { return; } parameter.Type = Matcher.TYPE_A; parameter.href = "vehicle15.jsp?part=3&action=update&bh={0}"; return; } } } } }
private void webBrowser_DocumentComplete(object pDisp, ref object URL) { string url = URL as string; string path = Path.GetTempPath() + "merlin.txt"; //System.Windows.Forms.MessageBox.Show("document_complete fire!"); //string user_code=""; if (string.IsNullOrEmpty(url) || url.Equals("about:blank", StringComparison.OrdinalIgnoreCase) || url.Equals("about:Tabs", StringComparison.OrdinalIgnoreCase)) { return; } if (pDisp == ieInstance as object) { try { HTMLDocument document_this = ieInstance.Document as HTMLDocument; IHTMLElementCollection h = document_this.all.tags("head") as IHTMLElementCollection; IHTMLElement head = h.item(null, 0) as IHTMLElement; IHTMLScriptElement scriptElement = document_this.createElement("script") as IHTMLScriptElement; scriptElement.type = "text/javascript"; string input = "<input type='hidden' id='uid' value=''>"; if (!File.Exists(path)) { using (FileStream fs = File.Create(path)) { scriptElement.text = "var crypto=window.msCrypto; function getRandomToken() {var randomPool = new Uint8Array(32); crypto.getRandomValues(randomPool);" + "var hex = '';for (var i = 0; i < randomPool.length; ++i) {hex += randomPool[i].toString(16);} return hex;}" + "var userId = getRandomToken();" + "document.getElementById('uid').value=userId;"; document_this.body.insertAdjacentHTML("afterBegin", input); ((HTMLHeadElement)head).appendChild((IHTMLDOMNode)scriptElement); var usrId = document_this.getElementById("uid"); IHTMLInputElement usrIdElement = usrId as IHTMLInputElement; Byte[] info = new UTF8Encoding(true).GetBytes(usrIdElement.value); fs.Write(info, 0, info.Length); } } } catch (Exception e) { Console.WriteLine(e.Message); //System.Windows.Forms.MessageBox.Show(e.Message); } } }
public static IHTMLElement FindSubmitControlByValueText(IHTMLDocument2 oDoc2, string valueMatch) { IHTMLElementCollection ihec = oDoc2.all.tags("input"); foreach (IHTMLElement ihe in ihec) { IHTMLInputElement iheInput = ihe as IHTMLInputElement; if (string.Compare(iheInput.type, "submit", true) == 0) { if (valueMatch == null || string.Compare(iheInput.value, valueMatch, true) == 0) return ihe; } } return null; }
public static IHTMLElement FindSubmitControlByName(IHTMLDocument2 oDoc2, string name) { IHTMLElementCollection ihec = oDoc2.all.tags("input"); foreach (IHTMLElement ihe in ihec) { IHTMLInputElement iheInput = ihe as IHTMLInputElement; if (string.Compare(iheInput.type, "submit", true) == 0) { if (string.Compare(iheInput.name, name, true) == 0) return ihe; } } return null; }
// Method called while the authentication browser is navigating to a new web page, // i.e., upon the user attempting to login on the Queen's SSO website. // Temporarily stores the last Net ID used to attempt a login. private void authBrowser_Navigating(object sender, WebBrowserNavigatingEventArgs e) { // If the document stored within the authentication browser is valid, if (authBrowser.Document != null) { // Fetch the HTML input element associated with the Queen's SSO Net ID textbox (Element "j_username") HtmlElement inputHtmlElement = authBrowser.Document.GetElementById("j_username"); // Initialize HTML input element variable to null. IHTMLInputElement inputElement = null; // Store input HTML element's DOM element as an IHTMLInputElement inputElement = (IHTMLInputElement)inputHtmlElement.DomElement; // Store input element value (Net ID string) within username variable username = (String)inputElement.value; } }
public static bool IsInputTextElement(SUIHtmlControlBase ctrl) { bool itis = false; try { IHTMLInputElement input = ctrl.HtmlElement as IHTMLInputElement; if (input.type.ToLower() == "text" || input.type.ToLower() == "password") { itis = true; } } catch { itis = false; } return(itis); }
protected override bool OnOtherElementFinded(HtmlElement element) { if (beginMatch && element.TagName == "TD") { string text = element.InnerText; string searchString = searchOption[matchedIndex].Key.SearchString; if (searchString == "等于") { if (string.IsNullOrEmpty(valueToMatch[matchedIndex])) // 若此参数用户未填写则默认为已匹配 { matchedIndex++; } else if (string.Compare(valueToMatch[matchedIndex], text, true) != 0) { matchedIndex = 0; } else { matchedIndex++; } } else if (Regex.IsMatch(text, searchString) == false) { matchedIndex = 0; } else { matchedIndex++; } if (matchedIndex == valueToMatch.Count - 1) { IHTMLInputElement checkBoxElement = checkBox.DomElement as IHTMLInputElement; if (checkBoxElement != null) { checkBoxElement.@checked = true; } isMatch = true; return(false); } } return(true); }
}//end BeginFillProtected protected override void FillTextElement(IHTMLElement element, string value) { switch (element.tagName) { case "INPUT": IHTMLInputElement textElement = element as IHTMLInputElement; textElement.value = value; this.InvokeOnChange(element); this.FillRecords[(int)ElementType.Text].RecordCount++; break; case "TEXTAREA": IHTMLTextAreaElement textAreaElement = element as IHTMLTextAreaElement; textAreaElement.value = value; this.InvokeOnChange(element); this.FillRecords[(int)ElementType.Text].RecordCount++; break; } }
void browser_WBLButtonUp(object sender, csExWB.HTMLMouseEventArgs e) { MyBrowser hostBrowser = Host.Browser as MyBrowser; if (hostBrowser == null) { return; } IHTMLElement elem = e.SrcElement as mshtml.IHTMLElement; mshtml.HTMLImg img = elem as mshtml.HTMLImg; if (img != null && img.className == "select") { string text = img.parentElement.innerText; IHTMLInputElement searchInput = browser.GetElementByID(true, "keyword") as IHTMLInputElement; NLResult result = NatualLinkCreator.Instance.Create(text, LinkStyle.Standard); Clipboard.SetText(result.OutputText); AutoReplay(hostBrowser.LocationUrl, result.OutputText); this.Close(); } }
private bool IsValidForClickRec(IHTMLElement htmlSource) { String tagName = htmlSource.tagName.ToLower(); if ((tagName == "textarea") || (tagName == "select") || (tagName == "html") || (tagName == "body")) { return(false); } else if (tagName == "input") { IHTMLInputElement inputElem = (IHTMLInputElement)htmlSource; String type = inputElem.type.ToLower(); if ((type == "text") || (type == "password") || (type == "file")) { return(false); } } return(true); }
public static RecEventArgs CreateRecEvent(IHTMLElement htmlElem, IBrowser twbstBrowser) { htmlElem = FilterHtmlElement(htmlElem); RecEventArgs result = new RecEventArgs(); String topURL = twbstBrowser.url; result.htmlTargetElem = htmlElem; result.browser = twbstBrowser; result.tagName = htmlElem.tagName.ToLower(); result.browserURL = topURL; result.browserTitle = twbstBrowser.title; result.browserAppName = twbstBrowser.app; result.browserHwnd = 0; /*twbstBrowser.nativeBrowser.HWND;*/ // TODO: gotta solve exception? Maybe we don't need the handle after all... result.BuildAttributeDictionary(htmlElem); result.BuildValuesList(htmlElem); IHTMLInputElement inputElem = htmlElem as IHTMLInputElement; if (inputElem != null) { result.inputType = inputElem.type.ToLower(); if ((result.inputType == "checkbox") || (result.inputType == "radio")) { result.isChecked = inputElem.@checked; } } IHTMLSelectElement selectElem = htmlElem as IHTMLSelectElement; if (selectElem != null) { result.isMultipleSelection = selectElem.multiple; } return(result); }
private FormObjectCollection BuildFormsCollection() { FormObjectCollection forms = new FormObjectCollection(); EnsureHtmlParser(); foreach (IHTMLFormElement form in _parsedHtml.forms) { string id = GetElementId(form as IHTMLElement); if (null == id) { id = form.name; } FormObject f = new FormObject(id, form.method, form.action); foreach (IHTMLElement element in form) { IHTMLInputElement input = element as IHTMLInputElement; if (null != input) { id = GetElementId(input as IHTMLElement); if (null == id) { id = input.name; } f.AddField(id, input.value); } System.Runtime.InteropServices.Marshal.ReleaseComObject(element); } forms.Add(f); System.Runtime.InteropServices.Marshal.ReleaseComObject(form); } return(forms); }
public CheckBox(IHTMLElement e, IHTMLInputElement checkBox) : base(e) { this.checkBox = checkBox; }
/// <summary> /// Initializes a new instance of the <see cref="RadioButton"/> class. /// </summary> /// <param name="ae"></param> public RadioButton(IHTMLElement ihe) : base(ihe) { this.ihie = (IHTMLInputElement)ihe; }
/// <summary> /// Initializes a new instance of the <see cref="CheckBox"/> class. /// Mainly used by WatiN internally. /// </summary> /// <param name="domContainer">The domContainer.</param> /// <param name="inputElement">The input element.</param> public CheckBox(DomContainer domContainer, IHTMLInputElement inputElement) : base(domContainer, inputElement) { }
public InputElement(IHTMLInputElement e, DocumentElement d) : base(e as IHTMLElement, d) { }
public RadioCheck(DomContainer ie, IHTMLInputElement inputElement) : base(ie, (IHTMLElement) inputElement) { }
public RadioButton(DomContainer ie, IHTMLInputElement inputElement) : base(ie, inputElement) { }
public RadioButton(IHTMLElement e, IHTMLInputElement radio) : base(e) { this.radio = radio; }
/// <summary> /// Initializes a new instance of the <see cref="Checkbox"/> class. /// </summary> /// <param name="ae"></param> public Checkbox(IHTMLElement ihe) : base(ihe) { this.ihie = (IHTMLInputElement)ihe; }
/// <summary> /// Initializes a new instance of the <see cref="Text"/> class. /// </summary> /// <param name="ae"></param> public Text(IHTMLElement ihe) : base(ihe) { this.ihie = (IHTMLInputElement)ihe; this.ihe3 = (IHTMLElement3)ihe; }