Example #1
0
 public void AddProtocolToUrlIfOmmitted()
 {
     using (var ie = new IE("www.google.com"))
     {
         Assert.That(ie.Url, Text.StartsWith("http://"));
     }
 }
        public void WhenOnBeforeUnloadReturnJavaDialogIsShown_ClickingOnCancelShouldKeepIEOpen()
        {
            using (var ie = new IE(OnBeforeUnloadJavaDialogURI))
            {
                var returnDialogHandler = new ReturnDialogHandler();
                ie.AddDialogHandler(returnDialogHandler);

                var hWnd = ie.hWnd;

                // can't use ie.Close() here cause this will cleanup the registered
                // returnDialogHandler which leads to a timeout on the WaitUntilExists
                var internetExplorer = (IWebBrowser2)ie.InternetExplorer;
                internetExplorer.Quit();

                returnDialogHandler.WaitUntilExists();
                returnDialogHandler.CancelButton.Click();

                Thread.Sleep(2000);
                Assert.IsTrue(Browser.Exists<IE>(new AttributeConstraint("hwnd", hWnd.ToString())));

                // finally close the ie instance
                internetExplorer.Quit();
                returnDialogHandler.WaitUntilExists();
                returnDialogHandler.OKButton.Click();
            }
        }
Example #3
0
        public void UseLambasSpeedTest()
        {
            using (var ie = new IE(BaseWatiNTest.MainURI))
            {
                var textFieldStart = ie.TextField(t => t.Name == "TextareaName");

                const int numberOfLookUps = 500;

                StopWatch stopWatch1 = new StopWatch();
                stopWatch1.Start();

                for (var i = 0; i < numberOfLookUps; i++)
                {
                    var textField = ie.TextField(t => t.Name == "TextareaName");
                    Assert.That(textField.Exists);
                }
                stopWatch1.Stop();

                var stopWatch2 = new StopWatch();
                stopWatch2.Start();

                for (var i = 0; i < numberOfLookUps; i++)
                {
                    var textField = ie.TextField(Find.ByName("TextareaName"));
                    Assert.That(textField.Exists);
                }
                stopWatch2.Stop();

                Console.WriteLine("1: " + stopWatch1.TicksSpend / numberOfLookUps + " " + stopWatch1.TicksSpend + " " + stopWatch1.TicksSpend / 1000);
                Console.WriteLine("2: " + stopWatch1.TicksSpend / numberOfLookUps + " " + stopWatch2.TicksSpend + " " + stopWatch2.TicksSpend / 1000);
            }
        }
Example #4
0
 public void DoesFrameCodeWorkIfTwoBrowsersWithFramesAreOpen()
 {
     using (var ie2 = new IE(FramesetURI))
     {
         var contentsFrame = ie2.Frame(Find.ByName("contents"));
         Assert.IsFalse(contentsFrame.Html.StartsWith("<FRAMESET"), "inner html of frame is expected");
     }
 }
Example #5
0
        public void UsingLinqExtensionMethodsWithWatiN_1_3()
        {
            using (var ie = new IE("www.google.com"))
            {
                var button = ie.Buttons.Where(b => b.GetValue("name") == "btnG").First();

                Assert.That(button.GetValue("Name"), Is.EqualTo("btnG"));
            }
        }
Example #6
0
 public void CheckIEIsInheritingProperTypes()
 {
     using (var ie = new IE())
     {
         Assert.IsInstanceOfType(typeof (IE), ie, "Should be an IE instance");
         Assert.IsInstanceOfType(typeof (Browser), ie, "Should be a Browser instance");
         Assert.IsInstanceOfType(typeof (DomContainer), ie, "Should be a DomContainer instance");
     }
 }
Example #7
0
        public Browser GetBrowser(Uri uri)
        {
            if (ie == null)
            {
                ie = (IE) CreateBrowser(uri);
            }

            return ie;
        }
Example #8
0
        public void UsingLambdaExpressionsWithWatiN_1_3()
        {
            using (var ie = new IE("www.google.com"))
            {
                var textField = ie.TextField(t => t.Name == "q");

                Assert.That(textField.Name, Is.EqualTo("q"));
            }
        }
Example #9
0
        public void UploadVideo(IE ie, string filePath)
        {
            ie.Link(Find.ById("uploadVideo")).Click();

            var fu = ie.FileUpload(Find.ById("ctl00_cphAdmin_txtUploadVideo"));

            fu.Set(filePath);

            ie.Button(Find.ById("ctl00_cphAdmin_btnUploadVideo")).Click();
            ie.WaitForComplete();
        }
Example #10
0
        public void UploadImage(IE ie, string filePath)
        {
            ie.Link(Find.ById("uploadImage")).Click();

            var fu = ie.FileUpload(Find.ByClass("ImageUpload"));

            fu.Set(filePath);

            ie.Button(Find.ById("ctl00_cphAdmin_btnUploadImage")).Click();
            ie.WaitForComplete();
        }
        public void Search_for_watin_on_google_using_page_class()
        {
            using (var browser = new IE("http://www.google.com"))
            {
                var searchPage = browser.Page <GoogleSearchPage>();
                searchPage.SearchCriteria.TypeText("WatiN");
                searchPage.SearchButton.Click();

                Assert.IsTrue(browser.ContainsText("WatiN"));
            }
        }
Example #12
0
        public void UsingLinqQueryWithWatiN_1_3()
        {
            using (var ie = new IE("www.google.com"))
            {
                var buttons = from button in ie.Buttons
                              where button.GetValue("Name") == "btnG"
                              select button;

                Assert.That(buttons.First().GetValue("Name"), Is.EqualTo("btnG"));
            }
        }
Example #13
0
        private async void RefreshButton_Click(object sender, RoutedEventArgs e)
        {
            IsEnabled = false;
            using (var browser = new IE())
            {
                await System.Threading.Tasks.Task.Factory.StartNew(() => { _controller.RefreshTasks(browser); });
            }

            IsEnabled = true;
            this.Dispatcher.Invoke(sort);
        }
Example #14
0
        public ActionResult UpdateIE(FormCollection fc)
        {
            IE ie = new IE();

            ie.Id       = Convert.ToInt32(fc["Id"]);
            ie.Question = fc["Question"];
            ie.Answer   = fc["Answer"];
            dataRepository.UpdateIE(ie);
            TempData["Message"] = "Record has been updated Successfully";
            return(RedirectToAction("AddIE", "IE"));
        }
 private async void UpdateInfoButton_Click(object sender, RoutedEventArgs e)
 {
     using (var browser = new IE())
     {
         var task = (Task)this.DataContext;
         await System.Threading.Tasks.Task.Factory.StartNew(() =>
         {
             TaskScraper.UpdateTaskInfo(task, browser);
         });
     }
 }
Example #16
0
        public void UsingLinqQueryWithWatiN_1_3()
        {
            using (var ie = new IE("www.google.com"))
            {
                var buttons = from button in ie.Buttons
                              where button.GetValue("Name") == "btnG"
                              select button;

                Assert.That(buttons.First().GetValue("Name"), Is.EqualTo("btnG"));
            }
        }
Example #17
0
 public void NewIEInNewProcess()
 {
     using (var ie1 = new IE())
     {
         using (var ie2 = new IE(true))
         {
             Assert.IsNotNull(ie2, "create ie in new process returned null");
             Assert.AreNotEqual(ie1.ProcessID, ie2.ProcessID, "process id problem");
         }
     }
 }
Example #18
0
        private static void IEExistsAsserts(Constraint findByUrl)
        {
            Assert.IsFalse(IE.Exists(findByUrl));

            using (new IE(MainURI))
            {
                Assert.IsTrue(IE.Exists(findByUrl));
            }

            Assert.IsFalse(IE.Exists(findByUrl));
        }
Example #19
0
File: Rival.cs Project: minskowl/MY
        protected static void FillUser(User user, Table userData, IE browser)
        {
            var parts = userData.TableRows[0].TableCells[1].Text.Split(separator, StringSplitOptions.RemoveEmptyEntries);

            user.Name = parts[0];
            if (parts.Length > 1)
            {
                user.Clan = Clan.Create(parts[1]);
            }
            user.FillSkils(browser);
        }
Example #20
0
        protected void Login(IE ie)
        {
            TextField tf = ie.TextField(Find.ByName(t => t.EndsWith("$UserName")));

            if (!tf.Exists)
            {
                return;             //already logged
            }
            tf.TypeText("Alkampfer");
            ie.TextField(Find.ByName(t => t.EndsWith("$Password"))).TypeText("12345");
            ie.Button(Find.ByName(b => b.EndsWith("$LoginButton"))).Click();
        }
Example #21
0
 private void CreateBrowser()
 {
     _panelBrowser = new ExtendedWebBrowser
     {
         Location = new Point(0, 195),
         Name     = "browserControl1",
         Size     = new Size(708, 528),
         TabIndex = 0
     };
     Controls.Add(_panelBrowser);
     WatinBrowser = new IE(_panelBrowser.ActiveXInstance, false);
 }
Example #22
0
        public void TestWatiNWithInjectedHTMLCode()
        {
            var html = "<HTML><input name=txtSomething><input type=button name=btnSomething value=Click></HTML>";

            using (var ie = new IE())
            {
                var document = ((IEDocument)ie.NativeDocument).HtmlDocument;
                document.writeln(html);

                Assert.That(ie.Button(Find.ByName("btnSomething")).Exists);
            }
        }
Example #23
0
        public void ShouldBeAbleToGetTheMetaTags()
        {
            // GIVEN
            using (var browser = new IE(MainURI))
            {
                // WHEN
                var metaTags = browser.ElementsWithTag("meta");

                // THEN
                Assert.That(metaTags.Count, Is.EqualTo(1));
            }
        }
Example #24
0
        public void AttachToIEByPartialTitle()
        {
            FailIfIEWindowExists("Ai", "AttachToIEByPartialTitle");

            using (new IE(MainURI))
            {
                using (var ieMainByTitle = IE.AttachTo <IE>(Find.ByTitle("Ai")))
                {
                    Assert.AreEqual(MainURI, ieMainByTitle.Uri);
                }
            }
        }
Example #25
0
 private void button1_Click(object sender, EventArgs e)
 {
     try
     {
         IE testIE = new IE("http://www.google.com");
         //FireFox testFF = new FireFox("http://www.google.com");
     }
     catch (Exception exc)
     {
         MessageBox.Show(exc.Message);
     }
 }
Example #26
0
        public void SetUp()
        {
            ie = new IE();

            ie.Refresh();
            ie.ClearCache();

            Settings.WaitForCompleteTimeOut = 240;

            // to hide IE window
            // ie.ShowWindow(WatiN.Core.Native.Windows.NativeMethods.WindowShowStyle.Hide);
        }
Example #27
0
        public void Purge(IE ie)
        {
            var trash = ie.Page <Trash>();

            ie.GoTo(trash.Url);
            ie.WaitForComplete();

            if (ie.Elements.Exists("btnPurgeAll"))
            {
                trash.PurgeAll.Click();
            }
        }
    static void Test2(IE
ie)
    {
        ie.doom
        ();
        object
        o
        =
        ie.Clone();
        ie.Dispose
        ();
    }
Example #29
0
        public void AttachToIEByUrl()
        {
            FailIfIEWindowExists("Ai", "AttachToIEByUrl");

            using (new IE(MainURI))
            {
                using (var ieMainByUri = IE.AttachToIE(Find.ByUrl(MainURI)))
                {
                    Assert.AreEqual(MainURI, ieMainByUri.Uri);
                }
            }
        }
Example #30
0
        public void ThenIShouldGoToTheSite(string site)
        {
            var page = IE.AttachTo <IE>(Find.ByUrl(new Regex(string.Format(".*{0}.*", site), RegexOptions.IgnoreCase)));

            Assert.IsNotNull(page);

            //close the browser if its a new window
            if (IE.AttachTo <IE>(Find.ByUrl(new Regex(".*" + SiteUrl + ".*", RegexOptions.IgnoreCase))) != null)
            {
                page.Close();
            }
        }
Example #31
0
 private IE TryToAttach()
 {
     try
     {
         return(IE.AttachToIE(Find.ByTitle("Ботва Онлайн - бесплатная онлайн игра")));
     }
     catch (Exception ex)
     {
         AppCore.LogFights.Warn("Несмогли присоедининться к существующему IE ", ex);
         return(null);
     }
 }
Example #32
0
        public void StartingDialogWatcherShouldAdhereToSetting()
        {
            Settings.Reset();

            Assert.That(Settings.AutoStartDialogWatcher, "Unexpected value for AutoStartDialogWatcher");

            Settings.AutoStartDialogWatcher = false;
            using (var ie = new IE())
            {
                Assert.That(ie.DialogWatcher, NUnit.Framework.SyntaxHelpers.Is.Null);
            }
        }
Example #33
0
 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 Browser FinishInitializationAndWaitForComplete(IE ie, SimpleTimer timer, bool waitForComplete)
        {
            ie.FinishInitialization(null);

            if (waitForComplete)
            {
                var ieWaitForComplete = new IEWaitForComplete((IEBrowser) ie.NativeBrowser) { Timer = timer };
                ie.WaitForComplete(ieWaitForComplete);
            }

            return ie;
        }
Example #35
0
        public void PromptDialogHandler()
        {
            var ie = IE.AttachToIE(Find.ByUrl(new Regex("TestEvents.html$")));

            var handler = new PromptDialogHandler("Hello");

            using (new UseDialogOnce(ie.DialogWatcher, handler))
            {
                ie.Button("showPrompt").Click();
            }
            Assert.That(ie.TextField("promptResult").Value, Is.EqualTo("Hello"), "input did not work. IE might be blocking the prompt dialog");
        }
Example #36
0
 public TimeCardPageDriver(IE ie)
 {
     WeekEndingList    = new WatinSelectList(ie, this, "WeekEnding1");
     WeekDateList      = new WatinSelectList(ie, this, "repHourlyTimeCards_ctl00_uclHourlyTime_ddlDate");
     EarningCodes      = new WatinSelectList(ie, this, "repHourlyTimeCards_ctl00_uclHourlyTime_ddlEarnCode");
     ContractLines     = new WatinSelectList(ie, this, "repHourlyTimeCards_ctl00_uclHourlyTime_udfControl_udf1_ddlValue");
     ContractNumbers   = new WatinSelectList(ie, this, "repHourlyTimeCards_ctl00_uclHourlyTime_udfControl_udf2_ddlValue");
     ActivityIDs       = new WatinSelectList(ie, this, "repHourlyTimeCards_ctl00_uclHourlyTime_udfControl_udf3_ddlValue");
     ProjectIDs        = new WatinSelectList(ie, this, "repHourlyTimeCards_ctl00_uclHourlyTime_udfControl_udf4_ddlValue");
     Hours             = new WatinTextField(ie, this, "repHourlyTimeCards_ctl00_uclHourlyTime_txtHours");
     SaveDetailsButton = new WatinLink(ie, this, "repHourlyTimeCards_ctl00_uclHourlyTime_lbtnSaveDetail");
 }
Example #37
0
 public void TestGoogle()
 {
     using (var browser = new IE())
     {
         browser.Setup();
         browser.GoTo("http://www.google.com.au/");
         browser.TextField(Find.ByName("q")).TypeText("Hello WatiN");
         browser.Button(Find.ByName("btnG")).Click();
         var link = browser.Link(Find.ByUrl("http://watin.org"));
         Assert.AreEqual(link.Text, "WatiN");
     }
 }
Example #38
0
 public void ShouldBeAbleToGetTheMetaTags()
 {
     // GIVEN
     using (var browser = new IE(MainURI))
     {
         // WHEN
         var metaTags = browser.ElementsWithTag("meta");
         
         // THEN
         Assert.That(metaTags.Count, Is.EqualTo(1));
     }
 }
Example #39
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);
        }
Example #40
0
        public bool inNewPostPage()
        {
            if (IE.title().contains(ExpectedTitle_NewPost))
            {
                "[BloggerAPI]: in new post page".info();
                return(true);
            }
            return(false);

            //if (true || IE.hasField("postingTitleField") && IE.hasField("postingHtmlBox"))
            //"[BloggerAPI]: in setNewPostContents, could not find html elements to insert data".error();
        }
        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();
        }
Example #42
0
        public static IE GetBrowser()
        {
            if (ScenarioContext.Current.ContainsKey(BROWSER_KEY))
            {
                return(ScenarioContext.Current.Get <IE>(BROWSER_KEY));
            }

            var browser = new IE();

            ScenarioContext.Current.Add(BROWSER_KEY, browser);
            return(browser);
        }
Example #43
0
        public void HtmlDialogCollectionShouldReturnOnlyItsOwnChildHtmlDialogs()
        {
            Ie.Button("popupid").Click();

            using (var ie2 = new IE(MainURI))
            {
                ie2.Button("popupid").Click();

                Assert.That(Ie.HtmlDialogs.Count, Is.EqualTo(1));
                Assert.That(ie2.HtmlDialogs.Count, Is.EqualTo(1));
            }
        }
        public void Should_also_handle_dialog_when_more_then_one_browser_is_open()
        {
            var not_used_ie = new IE();
            var approveConfirmDialog = new ConfirmDialogHandler();

            using (new UseDialogOnce(Ie.DialogWatcher, approveConfirmDialog))
            {
                Ie.Button(Find.ByValue("Show confirm dialog")).ClickNoWait();
                approveConfirmDialog.WaitUntilExists(5);
                approveConfirmDialog.OKButton.Click();
            }
            Ie.WaitForComplete();
        }
        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 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 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");
     }
 }
        public void PositionMousePointerInMiddleOfElementInFrame()
        {
            Settings.MakeNewIeInstanceVisible = true;
            Settings.HighLightElement = true;

            using (var ie = new IE(FramesetURI))
            {
                var button = ie.Frames[1].Links[0];
                PositionMousePointerInMiddleOfElement(button, ie);
                button.Flash();
                MouseMove(50, 50, true);
                Thread.Sleep(2000);
            }
        }
Example #49
0
        public void CloseBrowser()
        {
            if (ie == null) return;
            ie.Close();
            ie = null;
            if (IE.InternetExplorers().Count == 0) return;

            foreach (var explorer in IE.InternetExplorersNoWait())
            {
                Logger.LogDebug(explorer.Title + " (" + explorer.Url + ")");
                explorer.Close();
            }
            throw new Exception("Expected no open IE instances.");
        }
        public void CloseSpecificBrowserAlert()
		{
			Assert.AreEqual(0, Ie.DialogWatcher.Count, "DialogWatcher count should be zero");

		    var firstIE = Ie;
            firstIE.RunScript("document.title = 'firstIe'; ");

            using (var secondIe = new IE(TestPageUri,true))
            {
                secondIe.RunScript("document.title = 'secondIe'; ");
                // set up a second browser with an open dialog
                var secondAlertDialogHandler = new AlertDialogHandler();
                using (new UseDialogOnce(secondIe.DialogWatcher, secondAlertDialogHandler))
                {
                    secondIe.Button(Find.ByValue("Show alert dialog")).ClickNoWait();

                    secondAlertDialogHandler.WaitUntilExists(5);

                    // close the original message
                    var firstAlertDialogHandler = new AlertDialogHandler();
                    using (new UseDialogOnce(firstIE.DialogWatcher, firstAlertDialogHandler))
                    {
                        firstIE.Button(Find.ByValue("Show alert dialog")).ClickNoWait();

                        firstAlertDialogHandler.WaitUntilExists(5);

                        var message = firstAlertDialogHandler.Message;
                        firstAlertDialogHandler.OKButton.Click();

                        firstIE.WaitForComplete(5);

                        Assert.IsTrue(secondAlertDialogHandler.Exists(), "Original Alert Dialog should be open.");

                        Assert.AreEqual("This is an alert!", message, "Unexpected message");
                        Assert.IsFalse(firstAlertDialogHandler.Exists(), "Alert Dialog should be closed.");
                    }

                    // close the second message
                    secondAlertDialogHandler.OKButton.Click();

                    secondIe.WaitForComplete(5);

                    Assert.IsFalse(secondAlertDialogHandler.Exists(), "Alert Dialog should be closed.");
                }
            }
		}
        public void ShouldCancelCloseBrowser()
        {
            using (var ie = new IE())
            {
                var hwnd = ie.hWnd.ToString();

                // GIVEN
                var command = "window.close();";
                using (new UseDialogOnce(ie.DialogWatcher, new CloseIEDialogHandler(false)))
                {
                    // WHEN
                    ie.Eval(command);
                }

                // THEN
                Assert.That(Browser.Exists<IE>(Find.By("hwnd", hwnd)), Is.True, "Expected IE");
            }
        }
Example #52
0
 public static void SetBrowserEmulation(
     string programName, IE browserVersion)
 {
     if (!string.IsNullOrEmpty(programName))
     {
         programName = AppDomain.CurrentDomain.FriendlyName;
         RegistryKey regKey = Registry.CurrentUser.OpenSubKey(
             "Software\\Microsoft\\Internet Explorer\\Main" +
             "\\FeatureControl\\FEATURE_BROWSER_EMULATION", true);
         if (regKey != null)
         {
             try
             {
                 regKey.SetValue(programName, browserVersion,
                     RegistryValueKind.DWord);
             }
             catch (Exception ex)
             {
                 throw new Exception("Error writing to the registry", ex);
             }
         }
         else
         {
             try
             {
                 regKey = Registry.CurrentUser.OpenSubKey("Software" +
                     "\\Microsoft\\Internet Explorer\\Main" +
                     "\\FeatureControl", true);
                 regKey.CreateSubKey("FEATURE_BROWSER_EMULATION");
                 regKey.SetValue(programName, browserVersion,
                     RegistryValueKind.DWord);
             }
             catch (Exception ex)
             {
                 throw new Exception("Error accessing the registry", ex);
             }
         }
     }
 }
        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");
        }
Example #54
0
        public void ImportModel(IE.ModelFormat format)
        {
            int theformat=10;
            System.Windows.Forms.OpenFileDialog openDialog = new OpenFileDialog();

            string DataDir=((Environment.GetEnvironmentVariable("CASROOT")) + "\\..\\data");

            string filter="";

            switch (format)
            {
                case ModelFormat.BREP:
                    openDialog.InitialDirectory = (DataDir + "\\occ");
                    theformat=0;
                    filter= "BREP Files (*.brep *.rle)|*.brep; *.rle";
                    break;
                case ModelFormat.CSFDB:
                    theformat=1;
                    filter= "CSFDB Files (*.csfdb)|*.csfdb";
                    break;
                case IE.ModelFormat.STEP:
                    openDialog.InitialDirectory = (DataDir + "\\step");
                    theformat=2;
                    filter="STEP Files (*.stp *.step)|*.stp; *.step";
                    break;
                case IE.ModelFormat.IGES:
                    openDialog.InitialDirectory = (DataDir + "\\iges");
                    theformat=3;
                    filter="IGES Files (*.igs *.iges)|*.igs; *.iges";
                    break;
                default:
                    break;
            }
            openDialog.Filter = filter+"|All files (*.*)|*.*" ;
            if(openDialog.ShowDialog() == DialogResult.OK)
            {
                string filename = openDialog.FileName;
                if ( filename=="")
                    return;
                this.Cursor=System.Windows.Forms.Cursors.WaitCursor;
                if (!myView.TranslateModel(filename, theformat, true))
                MessageBox.Show("Cann't read this file", "Error!",
                    MessageBoxButtons.OK, MessageBoxIcon.Warning);
                this.Cursor=System.Windows.Forms.Cursors.Default;
            }
            this.myView.ZoomAllView();
        }
        public void TestMultipleIE()
        {
            using (var ie = new IE(TestEventsURI))
            {
                var handler = new ConfirmDialogHandler();
                try
                {
                    ie.AddDialogHandler(handler);
                    ie.Button(Find.ByValue("Show confirm dialog")).ClickNoWait();
                    handler.WaitUntilExists(5);
                    handler.OKButton.Click();
                }
                finally
                {
                    ie.RemoveDialogHandler(handler);
                }

                using (var ie2 = new IE(TestEventsURI))
                {
                    var handler2 = new ConfirmDialogHandler();
                    try
                    {
                        ie2.AddDialogHandler(handler2);
                        ie2.Button(Find.ByValue("Show confirm dialog")).ClickNoWait();
                        handler2.WaitUntilExists(5);
                        handler2.OKButton.Click();
                    }
                    finally
                    {
                        ie2.RemoveDialogHandler(handler2);
                    }
                }
            }
        }
Example #56
0
        public void TestWatiNWithInjectedHTMLCode()
        {
            var html = "<HTML><input name=txtSomething><input type=button name=btnSomething value=Click></HTML>";

            using(var ie = new IE())
            {
                var document = ((IEDocument)ie.NativeDocument).HtmlDocument;
                document.writeln(html);

                Assert.That(ie.Button(Find.ByName("btnSomething")).Exists);
            }
        }
Example #57
0
        public void Should_set_and_get_cookies()
        {
            using (var ie = new IE())
            {
                // Clear all cookies.
                ie.ClearCookies();

                // Ensure our test cookies don't exist from a previous run.
                Assert.IsNull(ie.GetCookie("http://1.watin.com/", "test-cookie"));
                Assert.IsNull(ie.GetCookie("http://2.watin.com/", "test-cookie"));

                // Create cookies for a pair of domains.
                ie.SetCookie("http://1.watin.com/", "test-cookie=abc; expires=Wed, 01-Jan-2020 00:00:00 GMT");
                Assert.AreEqual("test-cookie=abc", ie.GetCookie("http://1.watin.com/", "test-cookie"));

                ie.SetCookie("http://2.watin.com/", "test-cookie=def; expires=Wed, 01-Jan-2020 00:00:00 GMT");
                Assert.AreEqual("test-cookie=def", ie.GetCookie("http://2.watin.com/", "test-cookie"));

                CookieCollection collection = ie.GetCookiesForUrl(new Uri("http://2.watin.com/"));
                Assert.AreEqual(1, collection.Count);
                Assert.AreEqual(collection[0].Name, "test-cookie");
                Assert.AreEqual(collection[0].Value, "def");
            }
        }
Example #58
0
        public void Should_have_dialogwatcher_set_when_instantiated_by_calling_IntenetExplorers()
        {
            // GIVEN
            using(var ie1 = new IE())
            using(var ie2 = new IE())
            {
                // WHEN
                var internetExplorers = IE.InternetExplorers();

                // THEN
                Assert.That(internetExplorers.All(browser => browser.DialogWatcher != null));
            }
        }
Example #59
0
        public void Should_find_browser_with_opened_pdf_document()
        {
            // GIVEN
            using (var ie = new IE(@"C:\Development\watin\trunk\src\UnitTests\html\WatiN.pdf"))
            {
            //                var ie1 = IE.AttachToIENoWait(Find.ByTitle("watin.pdf"));
                Assert.That(Browser.Exists<IE>(Find.Any));
            }

            // WHEN

            // THEN
        }
Example #60
0
        public void Should_clear_cookies()
        {
            using (var ie = new IE())
            {
                // Clear all cookies.
                ie.ClearCookies();

                // Ensure our test cookies don't exist from a previous run.
                Assert.IsNull(ie.GetCookie("http://1.watin.com/", "test-cookie"), "Expected no cookies for 1.watin.com");
                Assert.IsNull(ie.GetCookie("http://2.watin.com/", "test-cookie"), "Expected no cookies for 2.watin.com");

                // Create cookies for a pair of domains.
                ie.SetCookie("http://1.watin.com/", "test-cookie=abc; expires=Wed, 01-Jan-2020 00:00:00 GMT");
                ie.SetCookie("http://2.watin.com/", "test-cookie=def; expires=Wed, 01-Jan-2020 00:00:00 GMT");

                // Clear cookies under one subdomain.
                ie.ClearCookies("http://1.watin.com/");

                // Ensure just the cookie of the first subdomain was deleted.
                Assert.IsNull(ie.GetCookie("http://1.watin.com/", "test-cookie"), "Expected no cookies for 1.watin.com after clear");
                Assert.AreEqual("test-cookie=def", ie.GetCookie("http://2.watin.com/", "test-cookie"), "Expected cookie for 2.watin.com");

                // Clear cookies under master domain.
                ie.ClearCookies("http://watin.com/");

                // Ensure the second subdomain's cookie was deleted this time.
                Assert.IsNull(ie.GetCookie("http://2.watin.com/", "test-cookie"), "Expected no cookies for 2.watin.com after ClearCookies");
            }
        }