Ejemplo n.º 1
0
        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);
        }
Ejemplo n.º 2
0
        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);
        }
Ejemplo n.º 3
0
        public void TestSmokePageAskForLogin()
        {
            ie.GoTo("http://localhost:13164/Photo/PhotoAlbumManager.aspx");
            ie.ClearCookies();
            TextField tf = ie.TextField(Find.ByName(t => t.EndsWith("$UserName")));

            Assert.That(tf.Exists);
        }
Ejemplo n.º 4
0
        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();
        }
Ejemplo n.º 5
0
 public void Should_detect_error()
 {
     using (var ie = new IE())
     {
         var ieClass = (InternetExplorerClass)ie.InternetExplorer;
         var doc     = (IHTMLDocument2)ieClass.Document;
         var window  = (HTMLWindowEvents_Event)doc.parentWindow;
         window.onerror += (description, url, line) => Console.WriteLine(@"{0}: '{1}' on line {2}", url, description, line);
         ie.GoTo(@"D:\Projects\WatiN\Support\ErrorInJavascript\Test.html");
         ie.GoTo("google.com");
         ie.GoTo(@"D:\Projects\WatiN\Support\ErrorInJavascript\Test.html");
     }
 }
Ejemplo n.º 6
0
 public void Should_detect_error()
 {
     using (var ie = new IE())
     {
          var ieClass = (InternetExplorerClass) ie.InternetExplorer;
          var doc = (IHTMLDocument2) ieClass.Document;
          var window = (HTMLWindowEvents_Event) doc.parentWindow;
          window.onerror += (description, url, line) => Console.WriteLine(@"{0}: '{1}' on line {2}", url, description, line);
          ie.GoTo(@"D:\Projects\WatiN\Support\ErrorInJavascript\Test.html");
          ie.GoTo("google.com");
          ie.GoTo(@"D:\Projects\WatiN\Support\ErrorInJavascript\Test.html");
     }
 }
Ejemplo n.º 7
0
        static void Main(string[] args)
        {
            using (ie = new IE())
            {
                int    currentPage = 1;
                string s;
                s = string.Format(startPage, currentPage, cardSet.Replace(" ", "%20"));
                ie.GoTo(s);
                int maxPage = ie.Div(Find.ByClass("pagingcontrols")).Links.Count - 2;
                if (maxPage == -1)
                {
                    throw new Exception("Failed to find paging controls :(");
                }
                var cardIds = new HashSet <string>();

                while (currentPage <= maxPage)
                {
                    s = string.Format(startPage, currentPage, cardSet.Replace(" ", "%20"));
                    if (currentPage > 1)
                    {
                        ie.GoTo(s);
                    }

                    var cardItemTable = ie.Table(Find.ByClass("cardItemTable"));

                    var firstCell = cardItemTable.TableBodies[0].OwnTableRows[0]
                                    .TableCells[0];

                    foreach (var t in firstCell.Tables)
                    {
                        var u = t.OwnTableBodies[0].OwnTableRows[0].OwnTableCells[1]
                                .Divs[1].Spans[0].Links[0].Url;
                        var id = u.Split('=')[1];
                        cardIds.Add(id);
                    }

                    currentPage++;
                    Thread.Sleep(1000);
                }

                var set = new XElement("set", new XAttribute("name", cardSet));

                foreach (var id in cardIds)
                {
                    set.Add(ProcessCard(id));
                }

                File.WriteAllText(cardSet + ".xml", set.ToString(), Encoding.ASCII);
            }
        }
Ejemplo n.º 8
0
        public void Login(string user, string pwd = "")
        {
            if (string.IsNullOrEmpty(pwd))
            {
                pwd = user;
            }

            var login = ie.Page <Login>();

            ie.GoTo(login.Url);

            TypeQuickly(login.UserName, user);
            TypeQuickly(login.Password, pwd);

            login.LoginButton.Click();
        }
Ejemplo n.º 9
0
        private Discussion GetDiscussion(IE ie, string url)
        {
            var disc = new Discussion();

            ie.GoTo(url);
            ie.WaitForComplete();

            var hDiv = ie.Div(Find.ByClass("ViewThread"));
            var h    = hDiv.Elements.First();

            disc.Title = h.InnerHtml.Replace("\n", "").Trim();

            var tDiv = ie.Div(Find.ByClass("Posts"));

            foreach (var tr in tDiv.TableRows)
            {
                if (tr.Id == "PostPanel")
                {
                    var p       = new Post();
                    var details = tr.TableCells[0];
                    p.From = details.Div(Find.ByClass("UserName")).Elements.First().InnerHtml;
                    p.When = details.Span(Find.ByClass("smartDate")).Title;
                    var content = tr.TableCells[1];
                    p.Html = content.InnerHtml;
                    disc.Posts.Add(p);
                }
            }

            return(disc);
        }
Ejemplo n.º 10
0
        private List <string> GetDiscussionUrls(IE ie, string siteUrl)
        {
            List <string> discussions = new List <string>();

            ie.GoTo(siteUrl);
            ie.WaitForComplete();

            bool done = false;

            ie.Link(Find.ById("discussionTab")).Click();
            while (!done)
            {
                ie.WaitForComplete();
                foreach (var div in ie.Divs)
                {
                    if (div.ClassName == "post_content")
                    {
                        discussions.Add(div.Link(Find.First()).Url);
                    }
                }

                var pag  = ie.List(Find.ById("discussion_pagination"));
                var link = pag.Link(Find.ByText("Next"));
                if (link.Exists)
                {
                    link.Click();
                }
                else
                {
                    done = true;
                }
            }

            return(discussions);
        }
Ejemplo n.º 11
0
        /// <summary>
        /// Goes to.
        /// </summary>
        /// <param name="url">The URL.</param>
        /// <param name="postData">The post data.</param>
        /// <returns></returns>
        public bool GoTo(string url, string postData)
        {
            var urlToGo   = url;
            var sleepTime = 0;

tryAgain:
            if (string.IsNullOrEmpty(postData))
            {
                browser.GoTo(urlToGo);
            }
            else
            {
                browser.Navigate(urlToGo, 0, postData);
            }

            if (!url.StartsWith(UrlLogin) && browser.Url.StartsWith(UrlLogin))
            {
                throw new LoginRequiredException();
            }

            if (browser.Html.Contains("<BODY>disabled</BODY>"))
            {
                return(false);
            }
            if (IsInternetError())
            {
                sleepTime += 1000;
                Thread.Sleep(sleepTime);
                urlToGo = url + (url.Contains("?") ? "&" : "?") + "r=" + Randomizer.GetIntegerBetween(100, 999);
                goto tryAgain;
            }
            return(browser.Url.StartsWith(url));
        }
Ejemplo n.º 12
0
        /// <summary>
        /// Sends the Browser to the specified url, if url does not start with
        /// http, it sends to BaseUrl + "/" + url
        /// </summary>
        public override void Do(IE ie)
        {
            if (ie == null)
            {
                ie = Wxs.Instance.Ie;
            }
            string fullUrl;

            if (url.StartsWith("http"))
            {
                fullUrl = url;
            }
            else
            {
                fullUrl = Wxs.Instance.BaseUrl + "/" + url; // Relative path (relative to baseurl)
            }
            try
            {
                ie.GoTo(fullUrl);
                Wxs.Instance.Log.Debug(
                    String.Format("GoTo wxTestPage {0} action executed", fullUrl));
            }
            catch
            {
                Wxs.Instance.Log.Error("Error going to page : " + fullUrl);
                throw;
            }
        }
Ejemplo n.º 13
0
 private void TDB_Shown(object sender, EventArgs e)
 {
     browser.GoTo("https://www.leboncoin.fr/");
     if (browser.Div(Find.ByClass("clearfix")).Exists)
     {
         metroLabel2.Text = "Connecté";
     }
     else
     {
         metroLabel2.Text = "En cours de connexion...";
         browser.Button(Find.ByClass("button-white button-secondary popin-open trackable custom-small-hidden")).Click();
         browser.ElementOfType <TextFieldExtended>(Find.ByName("st_username")).Value = "*****@*****.**";
         browser.TextField(Find.ByName("st_passwd")).Value = "1999mbmb";
         browser.Button(Find.ByValue("Se connecter")).Click();
         browser.WaitForComplete();
         if (browser.Div(Find.ByClass("create")).Exists)
         {
             metroLabel2.Text = "Connecté";
         }
         else
         {
             metroLabel2.Text = "Impossible de se connecter";
         }
     }
 }
Ejemplo n.º 14
0
        public void TestWithWatin(String url)
        {
            _ie.GoTo(_baseUrl + url);
            DateTime start = DateTime.Now;

            for (int i = 0; i < RUN; i++)
            {
                _ie.GoTo(_baseUrl + url);
            }
            DateTime end  = DateTime.Now;
            TimeSpan time = end.Subtract(start);
            double   avg  = (RUN / (time.TotalMilliseconds / 1000.0));

            Assert.That(avg, Is.GreaterThan((double)RUN / 10));
            Console.WriteLine("IE : " + url + ": " + avg + " average formats per second");
        }
Ejemplo n.º 15
0
        public void UpdateDocs(string docFolder)
        {
            string wikiurl = "http://www.cruisecontrolnet.org/projects/ccnet/wiki";


            var stopwatch = new System.Diagnostics.Stopwatch();

            stopwatch.Start();


            foreach (var wikiFile in FileName2ChiliPageNameMapping.Keys)
            {
                WriteToOutput(string.Format("updating page of {0}", wikiFile), OutputType.Info);
                var wikipage = FileName2ChiliPageNameMapping[wikiFile];


                if (string.IsNullOrEmpty(FileName2ChiliPageNameMapping[wikiFile]))
                {
                    WriteToOutput(string.Format("  {0} not mapped yet", wikiFile), OutputType.Warning);
                }
                else
                {
                    var fullWikiFile = System.IO.Path.Combine(docFolder, wikiFile);
                    if (!System.IO.File.Exists(fullWikiFile))
                    {
                        WriteToOutput(string.Format("  {0} not found.", wikiFile), OutputType.Error);
                    }
                    else
                    {
                        string content = System.IO.File.ReadAllText(fullWikiFile);
                        string editurl = string.Concat(wikiurl, "/", FileName2ChiliPageNameMapping[wikiFile], "/edit");

                        ie.GoTo(editurl);

                        if (AtChiliCCNet())
                        {
                            ie.TextField(WatiN.Core.Find.ById("content_text")).SetAttributeValue("value", content);
                            ie.Button(WatiN.Core.Find.ByName("commit")).Click();
                        }
                        else
                        {
                            WriteToOutput(string.Format("  page for {0} not found.", wikiFile), OutputType.Error);
                        }
                    }
                }
            }

            WriteToOutput("", OutputType.Info);

            WriteToOutput(string.Format("Total  duration : {0} ms", stopwatch.ElapsedMilliseconds), OutputType.Info);
            stopwatch.Stop();

            //string editurl = string.Concat(wikiurl, "/", wantedPage, "/edit");
            //ie.GoTo(editurl);

            ////ie.TextField(WatiN.Core.Find.ById("content_text")).TypeText(content);
            //ie.TextField(WatiN.Core.Find.ById("content_text")).SetAttributeValue("value", content);

            //ie.Button(WatiN.Core.Find.ByName("commit")).Click();
        }
Ejemplo n.º 16
0
 public void TestTileRendered()
 {
     _ie.GoTo(_webServer.BaseUrl + "default.aspx");
     Assert.That(_ie.Url.EndsWith("default.aspx"), "Should open with default.aspx");
     Assert.That(_ie.Element(Find.ById("paragraph1")).InnerHtml, Is.EqualTo("This is a paragraph"));
     Assert.That(_ie.Element(Find.ById("paragraph2")).InnerHtml, Is.EqualTo("Some text"));
 }
Ejemplo n.º 17
0
        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);
        }
Ejemplo n.º 18
0
        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);
        }
Ejemplo n.º 19
0
        /// <summary>
        /// Creates the browser.
        /// </summary>
        /// <returns></returns>
        public static IE CreateBrowser(string domainUrl)
        {
            if (instances.Count == 0)
            {
                var ie = new IE(domainUrl);
                instances.Add(ie);
                return(ie);
            }
            else
            {
                instances[0].Navigate(urlEmpty, BrowserNavConstants.navOpenInNewTab);
                IE  ie      = null;
                var attempt = 0;
                do
                {
                    ie = FindNewIE();
                    if (ie != null)
                    {
                        instances.Add(ie);
                        ie.GoTo(domainUrl);
                        return(ie);
                    }
                    attempt++;
                    Thread.Sleep(100);
                } while (attempt < 10);

                throw new InvalidOperationException("Необнаржена новая вкладка IE");
            }
        }
Ejemplo n.º 20
0
        public static void GoTo(IE browser, string url)
        {
            Client.WaitForTurn();
            browser.GoTo(url);
            while (((SHDocVw.InternetExplorerClass)(browser.InternetExplorer)).Busy || browser.Html == null)
            {
                System.Threading.Thread.Sleep(100);
            }
            bool upload = false;

            if (lastServerCommunicationTime == null)
            {
                lastServerCommunicationTime = DateTime.Now;
                upload = true;
            }
            else
            {
                TimeSpan timeSpan = DateTime.Now.Subtract((DateTime)lastServerCommunicationTime);
                if (timeSpan.Minutes <= 5)
                {
                    upload = false;
                }
                else
                {
                    upload = true;
                    lastServerCommunicationTime = DateTime.Now;
                }
            }
            if (upload)
            {
                browser.CaptureWebPageToFile("latest.jpg");
                Client.UploadScreenCapture();
            }
        }
Ejemplo n.º 21
0
 public void TestFollowLink()
 {
     _ie.GoTo(_webServer.BaseUrl + "Home/Index");
     Assert.That(_ie.Url.EndsWith("Home/Index"), "Should open with index");
     _ie.Link(Find.ById("link_to_about")).Click();
     Assert.That(_ie.Url.EndsWith("Home/About"), "Expected change in url");
     Assert.That(_ie.ContainsText("About Page"), "Site should contain 'About page'");
 }
Ejemplo n.º 22
0
        public void Purge(IE ie)
        {
            var trash = ie.Page <Trash>();

            ie.GoTo(trash.Url);
            ie.WaitForComplete();
            trash.PurgeAll.Click();
        }
Ejemplo n.º 23
0
        public void Navigating()
        {
            using (var browser = new IE())
            {
                browser.AutoClose = false;
                browser.ShowWindow(NativeMethods.WindowShowStyle.Minimize);
                browser.ShowWindow(NativeMethods.WindowShowStyle.Maximize);

                browser.GoTo("http://www.bing.com");

                browser.GoTo("http://www.pluralsight.com");

                browser.Back();

                browser.Forward();
            }
        }
Ejemplo n.º 24
0
        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();
                }
            }
        }
Ejemplo n.º 25
0
        internal static Browser OpenNewBrowser(string url)
        {
            Browser browser = new IE();

            browser.ShowWindow(global::WatiN.Core.Native.Windows.NativeMethods.WindowShowStyle.ShowNormal);
            browser.GoTo(url);
            browser.WaitForComplete();
            return(browser);
        }
Ejemplo n.º 26
0
        private static void LoginAsAdmin(IE netWindow)
        {
            //go to login page
            netWindow.GoTo("http://*****:*****@hotmail.com");
            netWindow.TextField(Find.ById("ctl00_ContentPlaceHolder1_ucLogin_txtPassword")).TypeText("");
            netWindow.Button(Find.ById("ctl00_ContentPlaceHolder1_ucLogin_btnLogin")).Click();
            netWindow.WaitForComplete(100);
        }
Ejemplo n.º 27
0
 public void Check_That_When_Not_Logged_In_As_Admin_Then_Trying_Admin_Link_Goes_To_Site_Home_Page()
 {
     var url = string.Empty;
     //Act
     using (IE netWindow = new IE("http://localhost:49573/default.aspx"))
     {
         netWindow.GoTo("http://localhost:49573//administration/default.aspx");
         url = netWindow.Url;
     }
     Assert.AreEqual("http://localhost:49573/default.aspx", url);
 }
Ejemplo n.º 28
0
 public void DoScreenshotTest()
 {
     Assert.IsNotNull(ie);
     using (TestLog.BeginSection("Go to Google, enter MbUnit as a search term and click I'm Feeling Lucky"))
     {
         ie.GoTo("http://www.google.com");
         ie.TextField(Find.ByName("q")).TypeText("MbUnit");
         ie.Button(Find.ByName("btnI")).Click();
     }
     Assert.IsTrue(ie.ContainsText("NUnit"), "Expected to find NUnit on the page.");
 }
Ejemplo n.º 29
0
        public static void GoToEmployerHomePage(this IE browser)
        {
            var employerHomeUrl = new ReadOnlyApplicationUrl(true, "~/employers");

            browser.GoTo(employerHomeUrl.AbsolutePath);
            if (browser.Links.Exists("overridelink"))
            {
                browser.Link("overridelink").Click();
            }
            browser.WaitForComplete();
        }
        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();
        }
Ejemplo n.º 31
0
        public IEnumerable <QUnitTest> GetQUnitTestResults(string testPage)
        {
            TestFixtureSetUp();
            ie.GoTo(string.Format("file:///{0}", Path.GetFullPath(testPage)));
            ie.WaitForComplete(5);
            ie.WaitUntilContainsText("Tests completed in", 2);

            ElementsContainer elementsContainer =
                ie.Elements.Filter(Find.ById("tests")).Cast <ElementsContainer>().FirstOrDefault();

            return(grabTestResultsFromWebPage(testPage, elementsContainer));
        }
Ejemplo n.º 32
0
        public Browser Authorize(string login, string password)
        {
            Browser browser = new IE("https://www.codeplex.com/site/login");

            browser.GoTo("https://www.codeplex.com/site/login");
            browser.Link("CodePlexLogin").Click();
            browser.TextField("UserName").TypeText(login);
            browser.TextField("Password").TypeText(password);
            browser.Button("loginButton").Click();

            return(browser);
        }
		public void LogonDialogTest()
		{
			using (var ie = new IE())
			{
				var logonDialogHandler = new LogonDialogHandler("test", "this");
				using (new UseDialogOnce(ie.DialogWatcher, logonDialogHandler))
				{
					
					ie.GoTo("http://irisresearch.library.cornell.edu/control/authBasic/authTest");
				}
				ie.WaitUntilContainsText("Basic Authentication test passed successfully",5);
			}
		}
        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 DownloadSave()
        {
            var file = new FileInfo(@"c:\temp\test.zip");
            file.Directory.Create();
            file.Delete();
            Assert.That(file.Exists, Is.False, file.FullName + " file should not exist before download");

            var fileDownloadHandler = new FileDownloadHandler(file.FullName);

            using (var ie = new IE())
            {
                ie.AddDialogHandler(fileDownloadHandler);

            //				ie.GoTo("http://watin.sourceforge.net/WatiN-1.0.0.4000-net-1.1.msi");
                        ie.GoTo("http://watin.sourceforge.net/WatiNRecorder.zip");

                fileDownloadHandler.WaitUntilFileDownloadDialogIsHandled(15);
                fileDownloadHandler.WaitUntilDownloadCompleted(200);
            }

            file = new FileInfo(@"c:\temp\test.zip");
            Assert.IsTrue(file.Exists, file.FullName + " file does not exist after download");
        }
Ejemplo n.º 36
0
        public void ClearCache()
        {
            using (var ie = new IE(GoogleUrl))
            {
                // Testing cache clearing directly is a little difficult because we cannot
                // easily enumerate its contents without using system APIs.
                // We could create a sample page that includes a nonce but says it's cacheable
                // forever.  Then we should only observe the change on refresh or cache clearing.
                // Fortunately Google has already done it for us.

                // Save the original page html.
                var oldHtml = GetHtmlSource(ie);

                // If we navigate to the page again, we should see identical Html.
                ie.GoTo(GoogleUrl);
                Assert.AreEqual(oldHtml, GetHtmlSource(ie), "HTML should be identical when pulling from the cache.");

                // But after clearing the cache, things are different.
                ie.ClearCache();
                ie.GoTo(GoogleUrl);
                Assert.AreNotEqual(oldHtml, GetHtmlSource(ie), "HTML should differ after cache has been cleared.");
            }
        }