public void CallingIEDisposeAfterIECloseShouldNotThrowAnExeption() { var ie = new IE(); ie.Close(); ie.Dispose(); }
public static string Goto(string Url, IE ie) { int i = 0; while (i < Loop) { i++; try { ie.GoTo(Url); ie.WaitForComplete(); return(string.Empty); } catch (Exception ex) { if (i == Loop) { return(ex.Message); } ie.Close(); Thread.Sleep(60000); ie.Reopen(); } } return(string.Empty); }
public override void TerminateFixture() { base.TerminateFixture(); WebServer.StopWebServer(); ie.Close(); }
public static bool TestInexistantLogin(IE browser, string webPage, out string message) { bool result = true; message = ""; browser = new IE(); try { browser.GoTo(webPage); browser.TextField(Find.ById(Login.UsernameInputText)).TypeText("sssssss"); browser.TextField(Find.ById(Login.PasswordInputText)).TypeText("ppppppppp"); browser.Button(Find.ByClass("formbutton")).Click(); if (browser.Child(Find.ByClass("ErrorMessage")) == null) { message = "Error message not displayed"; return(false); } browser.GoTo(webPage); browser.TextField(Find.ById(Login.ForgotPasswordEmailInputText)).TypeText("*****@*****.**"); browser.Div(Find.ById(Login.ForgotPasswordAjaxMessageDiv)).NextSibling.NextSibling.Click(); Thread.Sleep(1000); if (browser.Div(Find.ById(Login.ForgotPasswordAjaxMessageDiv)).InnerHtml == null) { message = "Ajax error message not displayed"; return(false); } } finally { browser.Close(); } return(result); }
public static void Stop() { if (ScenarioContext.Current.ContainsKey("browser")) { Current.Close(); } }
public static string Goto(String text, IE ie) { int i = 0; while (i < Loop) { i++; try { ie.GoTo(text); ie.WaitForComplete(); //ie.WaitUntilContainsText("message"); return(string.Empty); } catch (Exception ex) { if (i == Loop) { return(ex.Message); } ie.Close(); Thread.Sleep(60000); ie.Reopen(); } } return(string.Empty); }
public static bool TestEmptyLogin(IE browser, string webPage, out string message) { bool result = true; message = ""; browser = new IE(); try { browser.GoTo(webPage); browser.Button(Find.ByClass("formbutton")).Click(); if (browser.Child(Find.ByClass("ErrorMessage")) == null) { message = "Error message not displayed"; return(false); } browser.GoTo(webPage); browser.Div(Find.ById(Login.ForgotPasswordAjaxMessageDiv)).NextSibling.NextSibling.Click(); Thread.Sleep(1000); if (browser.Div(Find.ById(Login.ForgotPasswordAjaxMessageDiv)).InnerHtml == null) { message = "Ajax error message not displayed"; return(false); } } finally { browser.Close(); } return(result); }
public override bool Verify() { bool retValue = false; try { IE iepop = IE.AttachToIE(Find.ByTitle(new Regex(title))); if (iepop.ContainsText(Text)) { Wxs.Instance.Log.InfoFormat("Test : {0} passed", Text); retValue = true; } else { Wxs.Instance.Log.WarnFormat("Test : {0} failed", Text); } iepop.Close(); } catch (Exception ex) { Wxs.Instance.Log.ErrorFormat("Error: Exception {0} thrown executing Popup Test {1}!", ex.Message, Name); return(false); } return(retValue); }
private void processFile(Link link, XmlWriter writer) { string path = link.Url; string title = link.InnerHtml; writer.WritePage(title, path); Debug.WriteLine(title + " = " + path); var browser = new IE(path, false); foreach (Element header in browser.Elements) { if (header.TagName == "H2") { processHeader(header, writer, path); } if (header.TagName == "H4") { processSubHeader(header, writer, path); } } browser.Close(); }
public void CallingIEForceCloseAfterIECloseShouldThrowAnExeption() { var ie = new IE(); ie.Close(); ie.ForceClose(); }
/// <summary> /// Closes the given IE instance. /// </summary> /// <param name="ieInstance">The IE instance to be closed.</param> public static void CloseIEInstance(IE ieInstance) { if (ieInstance != null) { ieInstance.Close(); } }
private void btnClose_Click(object sender, EventArgs e) { if (_ie != null) { _ie.Close(); } Environment.Exit(0); }
public void TearDownTest() { browser.ClearCookies(rootUrl); browser.ClearCache(); browser.Close(); browser.Dispose(); browser = null; }
public void DoTestTeardown() { if (ie != null) { ie.Close(); ie.Dispose(); ie = null; } }
public void close() { if (_browser != null) { _browser.Close(); } _browser = null; }
static void Test() { IE browser = null; browser = new IE("http://www.google.com"); browser.TextField(Find.ByName("q")).TypeText("WatiN"); browser.Button(Find.ByName("btnG")).Click(); browser.Close(); }
private void Start(ref Exception exception, ref string output, string term) { IE browser = null; try { browser = IEBrowserHelper.GetBrowser(); browser.GoTo("https://www.google.com.br/"); browser.WaitForComplete(); TextField txtSearch = browser.TextField(Find.ByName("q")); if (txtSearch.Exists) { txtSearch.SetAttributeValue("value", term); } Element btnFind = browser.Element(Find.ByName("btnK")); if (btnFind.Exists) { btnFind.Click(); } var resultadosComplementares = browser.Div(Find.ByClass(p => p.Contains("kno-ecr-pt kno-fb-ctx"))); if (resultadosComplementares.Exists) { output = resultadosComplementares.OuterText; var resultadosComplementaresDescricao = browser.Div(Find.ByClass(p => p.Contains("kno-rdesc"))); if (resultadosComplementaresDescricao.Exists) { output += ": " + resultadosComplementaresDescricao.Spans[0].OuterText.Replace("\r\n", string.Empty); } } else { output = "O termo de busca não resultou em algo com a area de Resultados complementares"; } } catch (Exception e) { exception = e; } finally { //Close the browser if (browser != null) { browser.Close(); browser.Dispose(); } } }
void Close() { ie.ClearCache(); ie.ClearCookies(); ie.Close(); ie.Dispose(); complete(); }
public void Home_HasMvcStoreHasTitle_True() { var browser = new IE("http://localhost:1100/"); browser.BringToFront(); Assert.IsTrue(browser.ContainsText("ASP.NET MVC MUSIC STORE")); browser.Close(); }
private static void DownloadFiles() { var processes = from process in System.Diagnostics.Process.GetProcesses() where process.ProcessName == "iexplore" select process; foreach (var process in processes) { while (!process.HasExited) { process.Kill(); process.WaitForExit(); } } var browser = new IE("https://www.pseglinyportal.com/Account/Login.aspx"); browser.TextField(Find.ById("MainContent_UserName")).TypeText("ext-habera"); browser.TextField(Find.ById("MainContent_Password")).TypeText("917-295-1167pseg"); //browser.Button(Find.ByName("MainContent_btnsubmit")).Click(); System.Windows.Forms.SendKeys.SendWait("{ENTER}"); Console.WriteLine("Enter submitted"); Thread.Sleep(30000); //browser.WaitForComplete(); //for the first URL in the list, we need to download the html of the root report viewer //from there, we extract the "ReportSession" ID, then use that to pass to the report server so we can dynamically download the exact report we want browser.GoTo(singleGetReportURL); Console.WriteLine("Waiting to load " + singleGetReportURL); Thread.Sleep(30000); WriteFile(browser.Html, "tmp.html"); string reportSessionID = GetTargetValue("tmp.html", "ReportSession="); string controlID = GetTargetValue("tmp.html", "ControlID="); //noenw that we've got the session ID, execute the proper GET requests to download our CSV's foreach (var entry in urls) { string url = entry.Value.Replace("%ReportSession%", reportSessionID); url = url.Replace("%ControlID%", controlID); // DownLoadFile(ref browser, url); browser.GoTo(url); DownLoadFile("Drill Down Report - Internet Explorer"); Console.WriteLine("Waiting to load " + entry.Key); Thread.Sleep(30000); //WriteFile(browser.Html, entry.Key + ".html"); } browser.Close(); }
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(); }
private void cb3_SelectedIndexChanged(object sender, EventArgs e) { if (metroComboBox1.SelectedItem.ToString() == "Voitures" && cb3.SelectedItem.ToString() != "Marque") { Cursor.Current = Cursors.WaitCursor; browser.GoTo("https://www.leboncoin.fr/beta/ajax/request_template.html?template=fields%2Ffield_model&brand=" + cb3.SelectedItem.ToString()); browser.WaitForComplete(); Cursor.Current = Cursors.Default; cb4.DataSource = browser.SelectList(Find.ById("model")).AllContents; cb4.Enabled = true; browser.Close(); } }
public void DownloadRun() { var dhdl = new FileDownloadHandler(FileDownloadOptionEnum.Run); var ie = new IE(); ie.AddDialogHandler(dhdl); ie.WaitForComplete(); ie.GoTo("http://watin.sourceforge.net/WatiN-1.0.0.4000-net-1.1.msi"); dhdl.WaitUntilFileDownloadDialogIsHandled(5); dhdl.WaitUntilDownloadCompleted(20); ie.Close(); }
public void SaveImage(string filePath, string name) { string dirPath = @"C:\Users\test01\Desktop\Images"; string fileName = @"C:\Users\test01\Desktop\Images\" + name + ".jpg"; if (File.Exists(fileName)) { return; } try { ServicePointManager.Expect100Continue = true; ServicePointManager.SecurityProtocol = SecurityProtocolType.Tls12; // Create a new directory DirectoryInfo imageDirectory = Directory.CreateDirectory(dirPath); Console.WriteLine($"Directory '{Path.GetFileName(dirPath)}' was created successfully in {Directory.GetParent(dirPath)}"); // Image I'm trying to download from the web //string filePath = @"http://ilarge.lisimg.com/image/12056736/1080full-jessica-clements.jpg"; using (WebClient _wc = new WebClient()) { _wc.DownloadFile(new Uri(filePath), fileName); _wc.Dispose(); } Console.WriteLine("\nFile successfully saved."); } catch (Exception e) { while (e != null) { productItem.Close(); da.RecordDetailedErrorData(e, WebsiteID, 1); Console.WriteLine(e.Message + " Line: 438"); isErrorred = true; if (productItem != null) { productItem.ForceClose(); } } } if (System.Diagnostics.Debugger.IsAttached) { // Console.WriteLine("Press any key to continue . . ."); // Console.ReadKey(true); } }
public void DoTestTeardown() { if (ie != null) { if (TestContext.CurrentContext.Outcome == TestOutcome.Failed) { ie.CaptureWebPageToFile(@"C:\Documents and Settings\All Users\Favorites.png"); } ie.Close(); ie.Dispose(); ie = null; } }
public void DownloadOpen() { var dhdl = new FileDownloadHandler(FileDownloadOptionEnum.Open); var ie = new IE(); ie.AddDialogHandler(dhdl); ie.WaitForComplete(); ie.GoTo("http://watin.sourceforge.net/WatiNRecorder.zip"); dhdl.WaitUntilFileDownloadDialogIsHandled(5); dhdl.WaitUntilDownloadCompleted(20); ie.Close(); }
public void DownloadRun() { var dhdl = new FileDownloadHandler(FileDownloadOptionEnum.Run); var ie = new IE(); ie.AddDialogHandler(dhdl); ie.WaitForComplete(); ie.GoTo("http://watin.sourceforge.net/WatiN-1.0.0.4000-net-1.1.msi"); dhdl.WaitUntilFileDownloadDialogIsHandled(5); dhdl.WaitUntilDownloadCompleted(20); ie.Close(); }
public void TestBind() { if (Bind(dal, browser)) { Console.WriteLine("success"); this.WatinElement.Flash(10); } else { Console.WriteLine("failure"); } browser.Close(); }
public void close() { "closing WatiN_IE".info(); try { //if (IE.Disposed.isFalse()) IE.Close(); } catch (Exception ex) { ex.log("in WatiN_IE.close"); } detach(); }
public LambdAssert GoToUrlInFreshBrowser(string url) { using (IE ie = WebBrowser as IE) { ie.ClearCookies(); ie.ClearCache(); ie.Close(); } WebBrowser.Reopen(); WebBrowser.GoTo(url); WebBrowser.WaitForComplete(); return(LambdAssert); }
public void DownloadOpen() { var dhdl = new FileDownloadHandler(FileDownloadOptionEnum.Open); var ie = new IE(); ie.AddDialogHandler(dhdl); ie.WaitForComplete(); ie.GoTo("http://watin.sourceforge.net/WatiNRecorder.zip"); dhdl.WaitUntilFileDownloadDialogIsHandled(5); dhdl.WaitUntilDownloadCompleted(20); ie.Close(); }
static void Main(string[] args) { // Open an new Internet Explorer Window and // goto the google website. IE ie = new IE("http://www.google.com"); // Write out the HTML text of the body Console.WriteLine(ie.Text); // Close Internet Explorer and the console window immediately. ie.Close(); Console.Readkey(); }
public void CallingIEDisposeAfterIECloseShouldNotThrowAnExeption() { var ie = new IE(); ie.Close(); ie.Dispose(); }
public void CallingIEForceCloseAfterIECloseShouldThrowAnExeption() { var ie = new IE(); ie.Close(); ie.ForceClose(); }