public void ClickMe() { IE ie = new IE("http://localhost/AnthemNxt.Tests/ButtonsAndLabels.aspx"); Assert.Null(ie.Span(Find.ById("ctl00_ContentPlaceHolder_label")).Text); ie.Button(Find.ByName("ctl00$ContentPlaceHolder$button")).Click(); Assert.NotEqual("", ie.Span(Find.ById("ctl00_ContentPlaceHolder_label")).Text); // TODO: Check no postback occurred - how can we do this? ie.Close(); }
public void TestAlterDescription() { WatiN.Core.IE window = ie; ie.GoTo("http://localhost:13164/Photo/PhotoAlbumManager.aspx"); base.Login(ie); Button btn_ctl00ContentPlac = window.Button(Find.ByName("ctl00$ContentPlaceHolder1$PhotoAlbumManager1$grdPhotoAlbum$ctl04$Button1")); Assert.That(btn_ctl00ContentPlac.Exists); Span spn_ctl00_ContentPla = window.Span(Find.ById("ctl00_ContentPlaceHolder1_PhotoAlbumManager1_frmEdit_rptPhoto_ctl00_SinglePhotoThumbnail1_lblDescription")); Assert.That(spn_ctl00_ContentPla.Exists); //Added after the registration TextField txt_editCurrent = window.TextField(Find.ById("editCurrent")); Assert.That(txt_editCurrent.Exists); txt_editCurrent.WaitUntilExists(3000); window.GoTo("http://localhost:13164/Photo/PhotoAlbumManager.aspx"); btn_ctl00ContentPlac.Click(); spn_ctl00_ContentPla.Click(); txt_editCurrent.Click(); txt_editCurrent.AppendText("!!"); txt_editCurrent.KeyDown('\n'); }
public void RunQUnitTests() { using (var ie = new IE("http://localhost/CometGateway.Server.TelnetDemo/Test")) { var failed = ie.Span(Find.ByClass("failed")).InnerHtml; Assert.AreEqual("0", failed); } }
public void Check_That_When_Logged_In_As_Admin_Then_Add_Product_Works() { var result = false; using (IE netWindow = new IE("http://localhost:49573/default.aspx")) { LoginAsAdmin(netWindow); netWindow.Link(Find.ById("ctl00_ucHeader_lnkAdminPage")).Click(); #region hidden new way netWindow.Link(Find.ById(new Regex("AdminPage$"))); #endregion netWindow.WaitForComplete(); netWindow.Button(Find.ById("ctl00_ucHeader_lnkProductAdmin")).Click(); netWindow.WaitForComplete(); netWindow.Button(Find.ById("ctl00_ContentPlaceHolder1_RadDock1_C_btnAddProduct")).Click(); netWindow.WaitForComplete(); netWindow.TextField(Find.ById("ctl00_ContentPlaceHolder1_ucProduct_txtProductName")).TypeText(String.Format("Paul Test Product {0}", DateTime.Now.Ticks.ToString())); netWindow.SelectList(Find.ById("ctl00_ContentPlaceHolder1_ucProduct_ddlProductManufacturer")).SelectByValue("3"); netWindow.SelectList(Find.ById("ctl00_ContentPlaceHolder1_ucProduct_ddlCategoryList")).SelectByValue("2"); netWindow.WaitForComplete(100); netWindow.SelectList(Find.ById("ctl00_ContentPlaceHolder1_ucProduct_ddlSubCategoryList")).SelectByValue("2"); netWindow.WaitForComplete(); netWindow.Link(Find.ById("ctl00_ContentPlaceHolder1_ucProduct_btnAddCombo")).Click(); netWindow.WaitForComplete(); netWindow.TextField(Find.ById("ctl00_ContentPlaceHolder1_ucProduct_txtProductPrice")).TypeText("19.99"); netWindow.TextField(Find.ById("ctl00_ContentPlaceHolder1_ucProduct_txtProductModel")).TypeText("Paul Test Model 1"); netWindow.Link(Find.ById("ctl00_ContentPlaceHolder1_ucProduct_btnSave")).Click(); netWindow.WaitForComplete(); Span resultMessage = netWindow.Span(Find.ById("ctl00_ContentPlaceHolder1_ucProduct_ucMessage_lblMessage")); if (resultMessage.Text == "New Product created successfuly") { result = true; } } Assert.IsTrue(result); }
static void Main(string[] args) { //Делаем компилятор счастливым string username = ""; System.Console.WriteLine("OZWar Bot v1.0"); System.Console.WriteLine("Инициализация IE..."); //Инициализация ватина WatiN.Core.IE ieb = new IE("http://ozwar.ru/forum/index.php?app=core&module=global§ion=login"); ieb.Visible = false; int ii = 0; while (ii == 0) { System.Console.WriteLine("Авторизация..."); ieb.WaitForComplete(); //Вводим данные System.Console.WriteLine("Введите имя пользователя:"); username = System.Console.ReadLine(); System.Console.WriteLine("Введите пароль:"); string password = System.Console.ReadLine(); ieb.TextField(WatiN.Core.Find.ByName("ips_username")).TypeText(username); ieb.TextField(WatiN.Core.Find.ByName("ips_password")).TypeText(password); ieb.Button(WatiN.Core.Find.ByClass("input_submit")).Click(); ieb.WaitForComplete(); if (ieb.Link(WatiN.Core.Find.ByTitle(username)).Exists) { ii = 1; } } //Смотрим баланс ieb.GoTo(ieb.Link(WatiN.Core.Find.ByTitle(username)).Url); ieb.WaitForComplete(); System.Console.WriteLine("Баланс: " + ieb.Span(WatiN.Core.Find.ByClass("fc")).Text.ToString()); System.Console.WriteLine("Грузим ссылки..."); //Грузим ссылки var ar1 = new List<string>(); System.IO.StreamReader file = new System.IO.StreamReader(@"c:\list.txt"); string line; while ((line = file.ReadLine()) != null) { ar1.Add(line); } //Грузим фразы System.Console.WriteLine("Грузим фразы..."); var ar2 = new List<string>(); System.IO.StreamReader file2 = new System.IO.StreamReader(@"c:\phrases.txt"); string line2 = ""; while ((line2 = file2.ReadLine()) != null) { ar2.Add(line2); } int co = 0; while (co < ar1.Count) { ieb.GoTo(ar1[co]); ieb.WaitForComplete(); if (!ieb.Link(WatiN.Core.Find.ByTitle("Изменить")).Exists) { System.Console.WriteLine("Текущая ссылка: " + ar1[co]); int rnd = RandomInt(0, ar2.Count); System.Console.WriteLine("Пишем"); ieb.TextField(WatiN.Core.Find.ByName("Post")).TypeTextQuickly(ar2[rnd] + "[color=#222222]Эта информация тут только для дебага, цыц, вы этого не видели. Не, ну серьёзно. Ну, а раз видели, значит её сейчас, к сожалению, сейчас не станет. Это сообщение отправлено ботом OreNew, пожалуйста, не читайте его.[/color]"); ieb.Form(WatiN.Core.Find.ById("ips_fastReplyForm")).Submit(); ieb.WaitForComplete(); ieb.GoTo(ieb.Link(WatiN.Core.Find.ByTitle("Изменить")).Url); ieb.WaitForComplete(); ieb.TextField(WatiN.Core.Find.ByName("Post")).TypeText(ar2[rnd]); ieb.Form(WatiN.Core.Find.ById("postingform")).Submit(); System.Console.WriteLine("Выполнено"); ieb.GoTo("http://ozwar.ru/forum/index.php?/user/609-benderfromfuture/"); ieb.WaitForComplete(); System.Console.WriteLine("Баланс: " + ieb.Span(WatiN.Core.Find.ByClass("fc")).Text.ToString()); co++; } else { System.Console.WriteLine("Найдены следы нас!"); co++; } System.Console.WriteLine("Ссылки кончились, бот завершил свою работу"); ieb.Link(WatiN.Core.Find.ByTitle("Выход")).Click(); System.Console.WriteLine("Выход из профиля..."); System.Console.ReadLine(); } }
public static object FindControlInBrowserByID(IE ie, string strID, Enumerators.ControlType ctrl) { if (ctrl == Enumerators.ControlType.Span) { Span sp = ie.Span(Find.ById(strID)); Assert.IsTrue(sp.Exists, "Could not Find: " + strID); return sp; } else if (ctrl == Enumerators.ControlType.Link) { Link lnk = ie.Link(Find.ById(strID)); Assert.IsTrue(lnk.Exists, "Could not Find: " + strID); return lnk; } else if (ctrl == Enumerators.ControlType.Frame) { Frame iFrame = ie.Frame(Find.ById(strID)); return iFrame; } else if (ctrl == Enumerators.ControlType.Image) { Image img = ie.Image(Find.ById(strID)); Assert.IsTrue(img.Exists, "Could not Find: " + strID); return img; } else if (ctrl == Enumerators.ControlType.TableCell) { TableCell tCell = ie.TableCell(Find.ById(strID)); Assert.IsTrue(tCell.Exists, "Could not Find: " + strID); return tCell; } else if (ctrl == Enumerators.ControlType.Table) { Table tbl = ie.Table(Find.ById(strID)); Assert.IsTrue(tbl.Exists, "Could not Find: " + strID); return tbl; } else if (ctrl == Enumerators.ControlType.TableRow) { TableRow row = ie.TableRow(Find.ById(strID)); Assert.IsTrue(row.Exists, "Could not Find: " + strID); return row; } else if (ctrl == Enumerators.ControlType.CheckBox) { CheckBox chk = ie.CheckBox(Find.ById(strID)); Assert.IsTrue(chk.Exists, "Could not Find: " + strID); return chk; } else if (ctrl == Enumerators.ControlType.Button) { Button btn = ie.Button(Find.ById(strID)); Assert.IsTrue(btn.Exists, "Could not Find: " + strID); return btn; } else if (ctrl == Enumerators.ControlType.TextField) { TextField txt = ie.TextField(Find.ById(strID)); Assert.IsTrue(txt.Exists, "Could not Find: " + strID); return txt; } else if (ctrl == Enumerators.ControlType.SelectList) { SelectList sList = ie.SelectList(Find.ById(strID)); Assert.IsTrue(sList.Exists, "Could not Find: " + strID); return sList; } else if (ctrl == Enumerators.ControlType.Div) { Div division = ie.Div(Find.ById(strID)); Assert.IsTrue(division.Exists, "Could not Find: " + strID); return division; } else if (ctrl == Enumerators.ControlType.TableRow) { TableRow tRow = ie.TableRow(Find.ById(strID)); Assert.IsTrue(tRow.Exists, "Could not Find: " + strID); return tRow; } else if (ctrl == Enumerators.ControlType.FileUpload) { FileUpload fileUpload = ie.FileUpload(Find.ById(strID)); Assert.IsTrue(fileUpload.Exists, "Could not find: " + strID); return fileUpload; } else { return null; } }
public static object FindControlInBrowserByCustom(IE ie, string strCustomAttribute, string strToFind, Enumerators.ControlType ctrl) { if (ctrl == Enumerators.ControlType.Span) { Span sp = ie.Span(Find.By(strCustomAttribute, strToFind)); Assert.IsTrue(sp.Exists, "Could not Find: " + strToFind); return sp; } else if (ctrl == Enumerators.ControlType.Link) { Link lnk = ie.Link(Find.By(strCustomAttribute, strToFind)); Assert.IsTrue(lnk.Exists, "Could not Find: " + strToFind); return lnk; } else if (ctrl == Enumerators.ControlType.Frame) { Frame frame = ie.Frame(Find.By(strCustomAttribute, strToFind)); Assert.AreEqual(frame.Name, strToFind); return frame; } else if (ctrl == Enumerators.ControlType.Image) { Image img; if (strCustomAttribute == "src") { img = ie.Image(Find.BySrc(strToFind)); } else { img = ie.Image(Find.By(strCustomAttribute, strToFind)); } Assert.IsTrue(img.Exists, "Could not Find: " + strToFind); return img; } else if (ctrl == Enumerators.ControlType.TableCell) { TableCell tCell = ie.TableCell(Find.By(strCustomAttribute, strToFind)); Assert.IsTrue(tCell.Exists, "Could not Find: " + strToFind); return tCell; } else if (ctrl == Enumerators.ControlType.Table) { Table tbl = ie.Table(Find.By(strCustomAttribute, strToFind)); Assert.IsTrue(tbl.Exists, "Could not Find: " + strToFind); return tbl; } else if (ctrl == Enumerators.ControlType.TableRow) { TableRow row = ie.TableRow(Find.By(strCustomAttribute, strToFind)); Assert.IsTrue(row.Exists, "Could not Find: " + strToFind); return row; } else if (ctrl == Enumerators.ControlType.CheckBox) { CheckBox chk = ie.CheckBox(Find.By(strCustomAttribute, strToFind)); Assert.IsTrue(chk.Exists, "Could not Find: " + strToFind); return chk; } else if (ctrl == Enumerators.ControlType.Button) { Button btn = ie.Button(Find.By(strCustomAttribute, strToFind)); Assert.IsTrue(btn.Exists, "Could not Find: " + strToFind); return btn; } else if (ctrl == Enumerators.ControlType.TextField) { TextField txt = ie.TextField(Find.By(strCustomAttribute, strToFind)); Assert.IsTrue(txt.Exists, "Could not Find: " + strToFind); return txt; } else if (ctrl == Enumerators.ControlType.SelectList) { SelectList sList = ie.SelectList(Find.By(strCustomAttribute, strToFind)); Assert.IsTrue(sList.Exists, "Could not Find: " + strToFind); return sList; } else if (ctrl == Enumerators.ControlType.Div) { Div div = ie.Div(Find.By(strCustomAttribute, strToFind)); Assert.IsTrue(div.Exists, "Could not Find: " + strToFind); return div; } else { return null; } }
public WatinSpan(IE ie, PageDriver parent, string id) : base(id, ie.Span(Find.ById(id)), parent) { }
public string PassportCheck() { string strreturn = ""; using (var browser = new IE("https://www.world-check.com/portal/mod_perl/Login/")) { if (Find.ByName("username")) { browser.TextField(Find.ByName("username")).TypeText("nzrbrt0002"); browser.TextField(Find.ByName("password")).TypeText("Go8ahE5s"); browser.Image(Find.ByName("submitted")).Click(); } browser.GoTo("https://www.world-check.com/portal/mod_perl/PassportCheck"); browser.TextField(Find.ByName("givenName")).TypeText("Jim"); browser.TextField(Find.ByName("lastName")).TypeText("Smith"); browser.RadioButton(Find.ByName("sexg") && Find.ByValue("M")).Click(); browser.Span(Find.ById("issuingState-CAN")).Click(); browser.TextField(Find.ByName("dateOfBirthDay")).TypeText("29"); browser.TextField(Find.ByName("dateOfBirthMonth")).TypeText("05"); browser.TextField(Find.ByName("dateOfBirthYear")).TypeText("1978"); browser.TextField(Find.ByName("passportNumber")).TypeText("WL745488"); browser.TextField(Find.ByName("expireDateDay")).TypeText("10"); browser.TextField(Find.ByName("expireDateMonth")).TypeText("07"); browser.TextField(Find.ByName("expireDateYear")).TypeText("2014"); browser.Button(Find.ByValue("VERIFY")).Click(); var element = browser.Element(Find.ByClass("tablelinespacer")); var firsttd = element.NextSibling.NextSibling; strreturn = firsttd.Text.Replace("Lower Line:",""); //Assert.IsTrue(browser.ContainsText("WatiN")); } return strreturn; }