private static void LookFoAllLinks(IE ie) { int currentpageCounter = 0; var tmpUrl = string.Empty; const string nextPageUrl = "http://www.99acres.com/property-in-chennai-ffid-page-"; foreach (var currLink in ie.Links) { if (currLink.Url.Contains("b")) { Console.WriteLine(currLink.Url); try { if (currLink.Name.Contains("nextbutton")) { _nextPageElement = currLink; } } catch (Exception ex) { } try { if (currLink.GetAttributeValue("name").Contains("page")) { _firstPartOfAddress = currLink.Url.Substring(0, nextPageUrl.Length); tmpUrl = currLink.Url.Remove(0, nextPageUrl.Length); _lastPartOfAddress = tmpUrl.Substring(tmpUrl.IndexOf("?")); tmpUrl = tmpUrl.Substring(0, tmpUrl.IndexOf("?")); int.TryParse(tmpUrl, out currentpageCounter); if (currentpageCounter > _maxPageCounter) { _maxPageCounter = currentpageCounter; currentpageCounter = 0; } } } catch (Exception) { } } } }
private void treeView1_AfterSelect(object sender, TreeViewEventArgs e) { //foreach (WatiN.Core.TextField obj in ie.TextFields) //{ // obj.Highlight(false); //} //foreach (WatiN.Core.Button obj in ie.Buttons) //{ // obj.Highlight(false); //} //foreach (WatiN.Core.Div obj in ie.Divs) //{ // obj.Highlight(false); //}\ txtSelect.Text = e.Node.Text; string Value = e.Node.Text; if (Value.IndexOf(" = ") >= 0) { Value = Value.Split('=')[1].Trim(); } if (e.Node.FullPath.IndexOf("Div") >= 0) { if (txtSelect.Text.IndexOf("Name = ") >= 0) { Div div = ie.Div(Find.ByName(Value)); if (div != null && div.Exists) { div.Highlight(true); } } else { Div div = ie.Div(Find.ById(Value)); if (div != null && div.Exists) { div.Highlight(true); } } } else if (e.Node.FullPath.IndexOf("TextBox") >= 0) { TextField text = ie.TextField(Find.ByName(Value)); if (text != null && text.Exists) { text.Highlight(true); text.Select(); } } else if (e.Node.FullPath.IndexOf("Button") >= 0) { WatiN.Core.Button butt = ie.Button(Find.ByValue(Value)); if (butt != null && butt.Exists) { butt.Highlight(true); } } else if (e.Node.FullPath.IndexOf("Link") >= 0) { if (txtSelect.Text.IndexOf("Class = ") >= 0) { WatiN.Core.Link link = ie.Link(Find.ByClass(Value)); if (link != null && link.Exists) { link.Highlight(true); } } else { WatiN.Core.Link link = ie.Link(Find.ByText(Value)); if (link != null && link.Exists) { link.Highlight(true); } } } }
private static string RunControlConfirm(List <HControl> controls, IE ie) { int i = 0; string status = "Error"; while (i < Loop) { i++; foreach (HControl control in controls) { switch (control.Control.ToLower()) { case ControlType.AHref: { WatiN.Core.Link obj = MyWatiN.GetLink(ie, control); if (obj != null) { ConfirmDialogHandler approveConfirmDialog = new ConfirmDialogHandler(); using (new UseDialogOnce(ie.DialogWatcher, approveConfirmDialog)) { obj.ClickNoWait(); approveConfirmDialog.WaitUntilExists(); approveConfirmDialog.OKButton.Click(); ie.WaitForComplete(); return(String.Empty); } } break; } case ControlType.Link: { WatiN.Core.Link obj = MyWatiN.GetLink(ie, control); if (obj != null) { ConfirmDialogHandler approveConfirmDialog = new ConfirmDialogHandler(); using (new UseDialogOnce(ie.DialogWatcher, approveConfirmDialog)) { obj.ClickNoWait(); approveConfirmDialog.WaitUntilExists(); approveConfirmDialog.OKButton.Click(); ie.WaitForComplete(); return(String.Empty); } } break; } case ControlType.Button: { WatiN.Core.Button obj = MyWatiN.GetButton(ie, control); if (obj != null) { ConfirmDialogHandler approveConfirmDialog = new ConfirmDialogHandler(); using (new UseDialogOnce(ie.DialogWatcher, approveConfirmDialog)) { obj.ClickNoWait(); approveConfirmDialog.WaitUntilExists(); approveConfirmDialog.OKButton.Click(); ie.WaitForComplete(); return(String.Empty); } } break; } case ControlType.Div: { WatiN.Core.Div obj = MyWatiN.GetDiv(ie, control); if (obj != null) { ConfirmDialogHandler approveConfirmDialog = new ConfirmDialogHandler(); using (new UseDialogOnce(ie.DialogWatcher, approveConfirmDialog)) { obj.ClickNoWait(); approveConfirmDialog.WaitUntilExists(); approveConfirmDialog.OKButton.Click(); ie.WaitForComplete(); return(String.Empty); } } break; } } } Thread.Sleep(1000); } return(status); }
public static string RunControl(List <HControl> controls, string data, IE ie) { int i = 0; string status = "Error"; while (i < Loop) { i++; foreach (HControl control in controls) { switch (control.Control.ToLower()) { case ControlType.AHref: { WatiN.Core.Link obj = MyWatiN.GetLink(ie, control); if (obj != null) { obj.Click(); ie.WaitForComplete(); return(String.Empty); } break; } case ControlType.AHrefNoText: { ie.GoTo(control.Value); ie.WaitForComplete(); return(String.Empty); break; } case ControlType.Link: { WatiN.Core.Link obj = MyWatiN.GetLink(ie, control); if (obj != null) { obj.Click(); ie.WaitForComplete(); return(String.Empty); } break; } case ControlType.Button: { WatiN.Core.Button obj = MyWatiN.GetButton(ie, control); if (obj != null) { obj.Click(); ie.WaitForComplete(); return(String.Empty); } break; } case ControlType.Div: { WatiN.Core.Div obj = MyWatiN.GetDiv(ie, control); if (obj != null) { obj.Click(); ie.WaitForComplete(); return(String.Empty); } break; } case ControlType.Image: { WatiN.Core.Image obj = MyWatiN.GetImage(ie, control); if (obj != null) { obj.Click(); ie.WaitForComplete(); return(String.Empty); } break; } case ControlType.TextArea: { WatiN.Core.TextField obj = MyWatiN.GetTextField(ie, control); if (obj != null) { obj.Value = data; ie.WaitForComplete(); return(String.Empty); } break; } case ControlType.TextBox: { WatiN.Core.TextField obj = MyWatiN.GetTextField(ie, control); if (obj != null) { obj.Value = data; ie.WaitForComplete(); return(String.Empty); } break; } case ControlType.CheckBox: { WatiN.Core.CheckBox obj = MyWatiN.GetCheckBox(ie, control); if (obj != null) { obj.Checked = bool.Parse(data); ie.WaitForComplete(); return(String.Empty); } break; } } } Thread.Sleep(1000); } return(status); }
public static string RunControl(List <HControl> controls, string data, Div div, IE ie) { int i = 0; string status = "Error"; while (i < Loop) { i++; foreach (HControl control in controls) { switch (control.Control.ToLower()) { case ControlType.Link: { WatiN.Core.Link obj = MyWatiN.GetLink(div, control); if (obj != null) { obj.Click(); ie.WaitForComplete(); return(String.Empty); } break; } case ControlType.Button: { WatiN.Core.Button obj = MyWatiN.GetButton(div, control); if (obj != null) { obj.Click(); ie.WaitForComplete(); return(String.Empty); } break; } case ControlType.Image: { WatiN.Core.Image obj = MyWatiN.GetImage(div, control); if (obj != null) { obj.Click(); ie.WaitForComplete(); return(String.Empty); } break; } case ControlType.TextArea: { WatiN.Core.TextField obj = MyWatiN.GetTextField(div, control); if (obj != null) { obj.Value = data; ie.WaitForComplete(); return(String.Empty); } break; } case ControlType.TextBox: { WatiN.Core.TextField obj = MyWatiN.GetTextField(div, control); if (obj != null) { obj.Value = data; ie.WaitForComplete(); return(String.Empty); } break; } case ControlType.CheckBox: { WatiN.Core.CheckBox obj = MyWatiN.GetCheckBox(div, control); if (obj != null) { obj.Checked = true; ie.WaitForComplete(); return(String.Empty); } break; } } } if (i < Loop - 1) { Thread.Sleep(1000); } } return(status); }
public static bool CheckExist(List <HControl> controls, IE ie) { int i = 0; bool status = false; while (i < 2) { i++; foreach (HControl control in controls) { switch (control.Control.ToLower()) { case ControlType.AHref: { WatiN.Core.Link obj = MyWatiN.GetLink(ie, control); if (obj != null) { return(true); } break; } case ControlType.Link: { WatiN.Core.Link obj = MyWatiN.GetLink(ie, control); if (obj != null) { return(true); } break; } case ControlType.Button: { WatiN.Core.Button obj = MyWatiN.GetButton(ie, control); if (obj != null) { return(true); } break; } case ControlType.Div: { WatiN.Core.Div obj = MyWatiN.GetDiv(ie, control); if (obj != null) { return(true); } break; } case ControlType.Image: { WatiN.Core.Image obj = MyWatiN.GetImage(ie, control); if (obj != null) { return(true); } break; } case ControlType.TextArea: { WatiN.Core.TextField obj = MyWatiN.GetTextField(ie, control); if (obj != null) { return(true); } break; } case ControlType.TextBox: { WatiN.Core.TextField obj = MyWatiN.GetTextField(ie, control); if (obj != null) { return(true); } break; } case ControlType.CheckBox: { WatiN.Core.CheckBox obj = MyWatiN.GetCheckBox(ie, control); if (obj != null) { return(true); } break; } } } if (i < 1) { Thread.Sleep(1000); } } return(status); }