Пример #1
0
 public GameController(ILogger logger)
 {
     _logger           = logger;
     browser           = IE.AttachToIE(Find.ByTitle("Саровские башни"));
     browser.AutoClose = false;
     Trace("Find browser");
 }
Пример #2
0
        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);
        }
Пример #3
0
        public void AttachToIEByUrl()
        {
            FailIfIEWindowExists("Ai", "AttachToIEByUrl");

            using (new IE(MainURI))
            {
                using (var ieMainByUri = IE.AttachToIE(Find.ByUrl(MainURI)))
                {
                    Assert.AreEqual(MainURI, ieMainByUri.Uri);
                }
            }
        }
Пример #4
0
        public void AttachToIEByPartialTitle()
        {
            FailIfIEWindowExists("Ai", "AttachToIEByPartialTitle");

            using (new IE(MainURI))
            {
                using (var ieMainByTitle = IE.AttachToIE(Find.ByTitle("Ai")))
                {
                    Assert.AreEqual(MainURI, ieMainByTitle.Uri);
                }
            }
        }
Пример #5
0
 private IE TryToAttach()
 {
     try
     {
         return(IE.AttachToIE(Find.ByTitle("Ботва Онлайн - бесплатная онлайн игра")));
     }
     catch (Exception ex)
     {
         AppCore.LogFights.Warn("Несмогли присоедининться к существующему IE ", ex);
         return(null);
     }
 }
Пример #6
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");
        }
Пример #7
0
 public void AttachToIEWithZeroTimeout()
 {
     // Create a new IE instance so we can find it.
     using (new IE(MainURI))
     {
         var startTime = DateTime.Now;
         using (IE.AttachToIE(Find.ByUrl(MainURI), 0))
         {
             // Should return (within 1 second).
             Assert.Greater(1, DateTime.Now.Subtract(startTime).TotalSeconds);
         }
     }
 }
Пример #8
0
        public override bool Test()
        {
            if (popAction == null)
            {
                throw new ApplicationException("Popup action cannot be empty");
            }
            if (Actions.Count < 1)
            {
                throw new ApplicationException("Action list cannot be empty");
            }
            bool retValue = true;
            IE   iepop;

            try
            {
                popAction.Do(Wxs.Instance.Ie);
                if (UrlValue.Contains("*"))
                {
                    iepop = IE.AttachToIE(Find.ByUrl(new Regex(UrlValue.Replace("*", String.Empty))));
                }
                else
                {
                    iepop = IE.AttachToIE(Find.ByUrl(UrlValue));
                }
                Wxs.Instance.Log.InfoFormat("Attached to it! {0}", iepop.Text);
                foreach (wxAction action in Actions)
                {
                    action.Do(iepop);
                }
                foreach (wxVerifier ver in Verifications)
                {
                    if (ver.Verify())
                    {
                        Wxs.Instance.Log.InfoFormat("Verification {0} passed", ver.Name);
                    }
                    else
                    {
                        retValue = false;
                        Wxs.Instance.Log.WarnFormat("Verification {0} failed!", ver.Name);
                    }
                }
            }
            catch (Exception ex)
            {
                Wxs.Instance.Log.ErrorFormat("Error on PopTest {0}: {1}", Name, ex.Message);
                return(false);
            }
            iepop.Close();
            return(retValue);
        }
Пример #9
0
        public void NewIEClosedByDispose()
        {
            FailIfIEWindowExists("main", "IEClosedByDispose");

            using (new IE(MainURI))
            {
                using (var ie = IE.AttachToIE(Find.ByTitle("main")))
                {
                    Assert.AreEqual(MainURI, new Uri(ie.Url));
                }
            }

            Assert.IsFalse(IsIEWindowOpen("main"), "Internet Explorer not closed by IE.Dispose");
        }
Пример #10
0
        public void NewIEWithUriNotAutoClose()
        {
            FailIfIEWindowExists("main", "NewIEWithUriNotAutoClose");

            using (var ie = new IE(MainURI))
            {
                Assert.IsTrue(ie.AutoClose);
                ie.AutoClose = false;
            }

            Assert.IsTrue(IsIEWindowOpen("main"), "Internet Explorer should NOT be closed by IE.Dispose");

            IE.AttachToIE(Find.ByTitle("main"), 3).Close();
        }
Пример #11
0
        public void IENotFoundException()
        {
            var          startTime       = DateTime.Now;
            const int    timeoutTime     = 5;
            const string ieTitle         = "Non Existing IE Title";
            const string expectedMessage = "Could not find an IE window matching constraint: Attribute 'title' contains 'Non Existing IE Title' ignoring case. Search expired after '5' seconds.";

            try
            {
                // Time out after timeoutTime seconds
                startTime = DateTime.Now;
                using (IE.AttachToIE(Find.ByTitle(ieTitle), timeoutTime)) {}

                Assert.Fail(string.Format("Internet Explorer with title '{0}' should not be found", ieTitle));
            }
            catch (Exception e)
            {
                Assert.IsInstanceOfType(typeof(IENotFoundException), e);
                // add 1 second to give it some slack.
                Assert.Greater(timeoutTime + 1, DateTime.Now.Subtract(startTime).TotalSeconds);
                Console.WriteLine(e.Message);
                Assert.AreEqual(expectedMessage, e.Message, "Unexpected exception message");
            }
        }
Пример #12
0
 public void AttachToIEWithNegativeTimeoutNotAllowed()
 {
     IE.AttachToIE(Find.ByTitle("Bogus title"), -1);
 }