コード例 #1
0
        public void DeleteMessageUsingUid()
        {
            string uniqueSubject = Guid.NewGuid().ToString();

            this.SendTestEmail(uniqueSubject);

            GenericWait.Wait <bool, string>(this.IsEmailThere, new TimeSpan(0, 0, 1), new TimeSpan(0, 1, 0), uniqueSubject);

            List <MimeMessage> messageHeaders = this.EmailDriver.GetAllMessageHeaders();

            foreach (MimeMessage message in messageHeaders)
            {
                if (message.Subject.Equals(uniqueSubject))
                {
                    this.EmailDriver.DeleteMessage(this.EmailDriver.GetUniqueIDString(message));
                    break;
                }
            }

            messageHeaders = this.EmailDriver.GetAllMessageHeaders();

            foreach (MimeMessage message in messageHeaders)
            {
                if (message.Subject.Equals(uniqueSubject))
                {
                    Assert.Fail("Message " + uniqueSubject + " was not deleted");
                }
            }
        }
コード例 #2
0
        public void DeleteMessage()
        {
            string uniqueSubject = Guid.NewGuid().ToString();

            this.SendTestEmail(uniqueSubject);
            if (!GenericWait.Wait <bool, string>(this.IsEmailThere, new TimeSpan(0, 0, 1), new TimeSpan(0, 1, 0), uniqueSubject))
            {
                Assert.Fail("Failed to get message " + uniqueSubject);
            }

            List <MimeMessage> messageHeaders = this.EmailDriver.GetAllMessageHeaders();

            // find the email and delete it
            foreach (MimeMessage message in messageHeaders)
            {
                if (message.Subject.Equals(uniqueSubject))
                {
                    this.EmailDriver.DeleteMessage(message);
                    break;
                }
            }

            messageHeaders = this.EmailDriver.GetAllMessageHeaders();

            // Make sure it actually was deleted
            foreach (MimeMessage message in messageHeaders)
            {
                if (message.Subject.Equals(uniqueSubject))
                {
                    Assert.Fail("Message " + uniqueSubject + " was not deleted");
                }
            }
        }
コード例 #3
0
        /// <summary>
        /// Send keys to the lazy element
        /// </summary>
        /// <param name="text">The text to send to the lazy element</param>
        public void SendKeys(string text)
        {
            this.Log.LogMessage(MessageType.ACTION, $"Send keys '{text}' to '{this.userFriendlyName}'");

            GenericWait.Wait(
                () =>
            {
                IWebElement element = this.GetElement(this.GetRawVisibleElement);

                try
                {
                    this.ExecuteEvent(() => element.SendKeys(text), "SendKeys");
                }
                catch (Exception e)
                {
                    // Check if the value is set correctly , if so than we should say the send keys worked
                    string sub = text.Split(navigationChars)[0];
                    element    = this.GetElement(this.GetRawVisibleElement);

                    if (!sub.EndsWith(element.GetAttribute("value")))
                    {
                        throw e;
                    }

                    this.Log.LogMessage(MessageType.VERBOSE, "Sending keys caused an error, but text was entered.");
                }

                return(true);
            },
                this.WaitTime(),
                this.TimeoutTime());
        }
コード例 #4
0
ファイル: LazyElement.cs プロジェクト: cakriwut/MAQS
 /// <summary>
 /// Gets the CSS value for the given attribute
 /// </summary>
 /// <param name="attributeName">The given attribute name</param>
 /// <returns>The CSS value</returns>
 /// <example>
 /// <code source = "../SeleniumUnitTesting/LazyElementUnitTests.cs" region="LazyElementGetCssValue" lang="C#" />
 /// </example>
 public string GetCssValue(string attributeName)
 {
     return(GenericWait.WaitFor <string>(() =>
     {
         return this.GetElement(this.GetTheExistingElement).GetCssValue(attributeName);
     }));
 }
コード例 #5
0
ファイル: LazyElement.cs プロジェクト: cakriwut/MAQS
 /// <summary>
 /// Gets the current value of an element - Useful for get input box text
 /// </summary>
 /// <returns>The element's current value</returns>
 /// <example>
 /// <code source = "../SeleniumUnitTesting/LazyElementUnitTests.cs" region="LazyElementSendKeys" lang="C#" />
 /// </example>
 public string GetValue()
 {
     return(GenericWait.WaitFor <string>(() =>
     {
         return this.GetElement(this.GetTheVisibleElement).GetAttribute("value");
     }));
 }
コード例 #6
0
ファイル: GenericWaitTests.cs プロジェクト: ca-borja/MAQS
        public void WaitTryForAnyActionMultipleTimeTest()
        {
            DateTime start = DateTime.Now;
            TimeSpan max   = TimeSpan.FromSeconds(2);

            DateTime dateToTest      = DateTime.Now.AddSeconds(120);
            DateTime otherDateToTest = DateTime.Now.AddSeconds(1);

            GenericWait.WaitTryForAnyAction <bool>(
                "WaitForListOfActions",
                TimeSpan.FromSeconds(2),
                TimeSpan.FromSeconds(0.5),
                out bool result,
                () =>
            {
                Assert.IsTrue(dateToTest < DateTime.Now);
                return(true);
            },
                () =>
            {
                Assert.IsTrue(otherDateToTest < DateTime.Now);
                return(true);
            });
            TimeSpan duration = DateTime.Now - start;

            Assert.IsTrue(duration < max, "WaitTryForAnyActionMultipleTimeTest longer than " + duration);
        }
コード例 #7
0
        public void MarkAsSeenViaSearch()
        {
            string uniqueSubject = Guid.NewGuid().ToString();

            this.SendTestEmail(uniqueSubject);

            if (!GenericWait.Wait <bool, string>(this.IsEmailThere, new TimeSpan(0, 0, 1), new TimeSpan(0, 0, 30), uniqueSubject))
            {
                Assert.Fail("Failed to get message " + uniqueSubject);
            }

            Thread.Sleep(1000);

            // Get the email and mark it as seen
            MimeMessage message = this.EmailDriver.SearchMessages(SearchQuery.SubjectContains(uniqueSubject), false, true)[0];

            if (!GenericWait.Wait <bool, string>(this.IsEmailThere, new TimeSpan(0, 0, 1), new TimeSpan(0, 0, 30), uniqueSubject))
            {
                Assert.Fail("Refresh of " + uniqueSubject + " failed");
            }

            message = this.EmailDriver.SearchMessages(SearchQuery.SubjectContains(uniqueSubject), false)[0];

            List <IMessageSummary> flags = this.EmailDriver.GetEmailFlags(this.EmailDriver.GetUniqueIDString(message));

            Assert.IsTrue(flags[0].Flags.Value.HasFlag(MessageFlags.Seen), "Message not marked as read");

            this.EmailDriver.DeleteMessage(message);
        }
コード例 #8
0
ファイル: GenericWaitTests.cs プロジェクト: ca-borja/MAQS
        public void WaitUntilRetryTimeoutCompletes()
        {
            var result = GenericWait.WaitUntilTimeout(() => true, TimeSpan.FromSeconds(1), TimeSpan.FromSeconds(1));

            Assert.IsTrue(result);
            result = GenericWait.WaitUntilTimeout(() => false, TimeSpan.FromSeconds(1), TimeSpan.FromSeconds(1));
            Assert.IsFalse(result);
        }
コード例 #9
0
ファイル: GenericWaitTests.cs プロジェクト: ca-borja/MAQS
        public void PassObjectArrayUntilTest()
        {
            List <object> objects = new List <object>();

            objects.Add((object)"one");
            objects.Add((object)new Dictionary <int, Guid>());

            Assert.IsTrue(GenericWait.WaitUntil <object[]>(this.IsTwoParameters, objects.ToArray()), "Failed parameter array test");
        }
コード例 #10
0
ファイル: LazyElement.cs プロジェクト: cakriwut/MAQS
 /// <summary>
 /// Submit the lazy element
 /// </summary>
 /// <example>
 /// <code source = "../SeleniumUnitTesting/LazyElementUnitTests.cs" region="LazyElementSubmit" lang="C#" />
 /// </example>
 public void Submit()
 {
     GenericWait.WaitFor(() =>
     {
         IWebElement element = this.GetElement(this.GetTheExistingElement);
         this.ExecuteEvent(() => element.Submit(), "Submit");
         return(true);
     });
 }
コード例 #11
0
ファイル: GenericWaitTests.cs プロジェクト: ca-borja/MAQS
        public void PassObjectArrayForTest()
        {
            List <object> objects = new List <object>();

            objects.Add((object)"one");
            objects.Add((object)new Dictionary <int, Guid>());

            GenericWait.WaitFor <object[]>(this.IsTwoParameters, objects.ToArray());
        }
コード例 #12
0
ファイル: LazyElement.cs プロジェクト: cakriwut/MAQS
 /// <summary>
 /// Send keys to the lazy element
 /// </summary>
 /// <param name="keys">The keys to send to the lazy element</param>
 /// <example>
 /// <code source = "../SeleniumUnitTesting/LazyElementUnitTests.cs" region="LazyElementSendKeys" lang="C#" />
 /// </example>
 public void SendKeys(string keys)
 {
     GenericWait.WaitFor(() =>
     {
         IWebElement element = this.GetElement(this.GetTheVisibleElement);
         this.ExecuteEvent(() => element.SendKeys(keys), "SendKeys");
         return(true);
     });
 }
コード例 #13
0
ファイル: LazyElement.cs プロジェクト: cakriwut/MAQS
 /// <summary>
 /// Clear the lazy element
 /// </summary>
 /// <example>
 /// <code source = "../SeleniumUnitTesting/LazyElementUnitTests.cs" region="LazyElementClear" lang="C#" />
 /// </example>
 public void Clear()
 {
     GenericWait.WaitFor(() =>
     {
         IWebElement element = this.GetElement(this.GetTheVisibleElement);
         this.ExecuteEvent(() => element.Clear(), "Clear");
         return(true);
     });
 }
コード例 #14
0
 /// <summary>
 /// Get a mailbox by name
 /// </summary>
 /// <param name="mailbox">The mailbox name</param>
 /// <returns>The mailbox</returns>
 /// <example>
 /// <code source="../EmailUnitTests/EmailUnitWithDriver.cs" region="GetMailbox" lang="C#" />
 /// </example>
 public virtual IMailFolder GetMailbox(string mailbox)
 {
     return(GenericWait.WaitFor <IMailFolder>(() =>
     {
         CurrentMailBox = mailbox;
         CurrentFolder = EmailConnection.GetFolder(mailbox);
         CurrentFolder.Open(FolderAccess.ReadWrite);
         return CurrentFolder;
     }));
 }
コード例 #15
0
 /// <summary>
 /// Select a mailbox by name
 /// </summary>
 /// <param name="mailbox">The name of the mailbox</param>
 /// <example>
 /// <code source="../EmailUnitTests/EmailUnitWithDriver.cs" region="SelectMailbox" lang="C#" />
 /// </example>
 public virtual void SelectMailbox(string mailbox)
 {
     GenericWait.WaitFor <bool>(() =>
     {
         CurrentMailBox = mailbox;
         CurrentFolder  = EmailConnection.GetFolder(mailbox);
         CurrentFolder.Open(FolderAccess.ReadWrite);
         return(true);
     });
 }
コード例 #16
0
ファイル: GenericWaitTests.cs プロジェクト: ca-borja/MAQS
        public void WaitUntilTimeoutReturnsString()
        {
            var str    = "my string";
            var result = GenericWait.WaitUntilTimeout(
                () => str,
                TimeSpan.FromMilliseconds(500),
                TimeSpan.FromSeconds(1));

            Assert.AreEqual(str, result, "Wait result does not match the expected result of the method");
        }
コード例 #17
0
ファイル: GenericWaitTests.cs プロジェクト: ca-borja/MAQS
        public void CustomTimeoutWithParamTest()
        {
            DateTime start = DateTime.Now;
            TimeSpan max   = TESTTIMEOUT + TESTRETRY + TESTRETRY;

            GenericWait.Wait <string>(this.IsParamTestString, TESTRETRY, TESTTIMEOUT, false, "bad");
            TimeSpan duration = DateTime.Now - start;

            Assert.IsTrue(duration < max, "The max wait time should be no more than " + max + " but was " + duration);
        }
コード例 #18
0
ファイル: GenericWaitTests.cs プロジェクト: ca-borja/MAQS
        public void WaitUntilTimeoutReturnsTrue()
        {
            var result = GenericWait.WaitUntilTimeout(
                () => true,
                TimeSpan.FromSeconds(1),
                TimeSpan.FromSeconds(2),
                false);

            Assert.IsTrue(result, "Expected Wait to return true");
        }
コード例 #19
0
ファイル: GenericWaitTests.cs プロジェクト: ca-borja/MAQS
        public void WaitUntilTimeoutReturnsStringWithArgument()
        {
            var str    = "my string";
            var result = GenericWait.WaitUntilTimeout(
                (a) => a,
                TimeSpan.FromSeconds(1),
                TimeSpan.FromSeconds(2),
                str);

            Assert.AreEqual(str, result, "Passed argument and result do not match");
        }
コード例 #20
0
        /// <summary>
        /// Gets the CSS value for the given attribute
        /// </summary>
        /// <param name="propertyName">The given attribute/property name</param>
        /// <returns>The CSS value</returns>
        public string GetCssValue(string propertyName)
        {
            this.Log.LogMessage(MessageType.INFORMATION, $"Getting '{propertyName}' css value for lazy element '{this.userFriendlyName}'");

            return(GenericWait.Wait <string>(
                       () =>
            {
                return this.GetElement(this.GetRawExistingElement).GetCssValue(propertyName);
            },
                       Extend.GetWaitDriver(this.WebDriver).PollingInterval,
                       Extend.GetWaitDriver(this.WebDriver).Timeout));
        }
コード例 #21
0
        /// <summary>
        /// Gets the current value of an element - Useful for get input box text
        /// </summary>
        /// <returns>The element's current value</returns>
        public string GetValue()
        {
            this.Log.LogMessage(MessageType.INFORMATION, $"Getting value for lazy element '{this.userFriendlyName}'");

            return(GenericWait.Wait <string>(
                       () =>
            {
                return this.GetElement(this.GetRawVisibleElement).GetAttribute("value");
            },
                       Extend.GetWaitDriver(this.WebDriver).PollingInterval,
                       Extend.GetWaitDriver(this.WebDriver).Timeout));
        }
コード例 #22
0
        /// <summary>
        /// Gets the value for the given attribute
        /// </summary>
        /// <param name="attributeName">The given attribute name</param>
        /// <returns>The attribute value</returns>
        public string GetAttribute(string attributeName)
        {
            this.Log.LogMessage(MessageType.INFORMATION, $"Getting attribute '{attributeName}' for lazy element '{this.userFriendlyName}'");

            return(GenericWait.Wait <string>(
                       () =>
            {
                return this.GetElement(this.GetRawExistingElement).GetAttribute(attributeName);
            },
                       Extend.GetWaitDriver(this.WebDriver).PollingInterval,
                       Extend.GetWaitDriver(this.WebDriver).Timeout));
        }
コード例 #23
0
        /// <summary>
        /// Gets the Selected dropdown option from the Lazy element
        /// </summary>
        /// <returns>The selected option</returns>
        public string GetSelectedOptionFromDropdown()
        {
            this.Log.LogMessage(MessageType.INFORMATION, $"Getting Selected Option for lazy element '{this.userFriendlyName}'");

            return(GenericWait.Wait <string>(
                       () =>
            {
                return new SelectElement(this.GetElement(this.GetRawExistingElement)).SelectedOption.Text;
            },
                       Extend.GetWaitDriver(this.WebDriver).PollingInterval,
                       Extend.GetWaitDriver(this.WebDriver).Timeout));
        }
コード例 #24
0
        /// <summary>
        /// Gets the CSS value for the given attribute
        /// </summary>
        /// <param name="propertyName">The given attribute/property name</param>
        /// <returns>The CSS value</returns>
        public string GetCssValue(string propertyName)
        {
            this.Log.LogMessage(MessageType.INFORMATION, $"Getting '{propertyName}' css value for lazy element '{this.userFriendlyName}'");

            return(GenericWait.Wait <string>(
                       () =>
            {
                return this.GetElement(this.GetRawExistingElement).GetCssValue(propertyName);
            },
                       this.WaitTime(),
                       this.TimeoutTime()));
        }
コード例 #25
0
        /// <summary>
        /// Gets the current value of an element - Useful for get input box text
        /// </summary>
        /// <returns>The element's current value</returns>
        public string GetValue()
        {
            this.Log.LogMessage(MessageType.INFORMATION, $"Getting value for lazy element '{this.userFriendlyName}'");

            return(GenericWait.Wait <string>(
                       () =>
            {
                return this.GetElement(this.GetRawVisibleElement).GetAttribute("value");
            },
                       this.WaitTime(),
                       this.TimeoutTime()));
        }
コード例 #26
0
        /// <summary>
        /// Gets the value for the given attribute
        /// </summary>
        /// <param name="attributeName">The given attribute name</param>
        /// <returns>The attribute value</returns>
        public string GetAttribute(string attributeName)
        {
            this.Log.LogMessage(MessageType.INFORMATION, $"Getting attribute '{attributeName}' for lazy element '{this.userFriendlyName}'");

            return(GenericWait.Wait <string>(
                       () =>
            {
                return this.GetElement(this.GetRawExistingElement).GetAttribute(attributeName);
            },
                       this.WaitTime(),
                       this.TimeoutTime()));
        }
コード例 #27
0
        /// <summary>
        /// Gets the Selected dropdown option from the Lazy element
        /// </summary>
        /// <returns>The selected option</returns>
        public string GetSelectedOptionFromDropdown()
        {
            this.Log.LogMessage(MessageType.INFORMATION, $"Getting Selected Option for lazy element '{this.userFriendlyName}'");

            return(GenericWait.Wait <string>(
                       () =>
            {
                return new SelectElement(this.GetElement(this.GetRawExistingElement)).SelectedOption.Text;
            },
                       this.WaitTime(),
                       this.TimeoutTime()));
        }
コード例 #28
0
ファイル: GenericWaitTests.cs プロジェクト: ca-borja/MAQS
        public void WaitUntilTimeoutArgumentsTrue()
        {
            var str    = "my string";
            var result = GenericWait.WaitUntilTimeout(
                (a) => true,
                TimeSpan.FromMilliseconds(333),
                TimeSpan.FromSeconds(1),
                false,
                str);

            Assert.IsTrue(result, "Wait returned incorrect value");
        }
コード例 #29
0
        /// <summary>
        /// Gets the value of a JavaScript property of this element.
        /// </summary>
        /// <param name="propertyName">The name of the JavaScript property to get the value of.</param>
        /// <returns>The JavaScript property's current value. Returns a <see langword="null"/> if the value is not set or the property does not exist.</returns>
        public string GetDomProperty(string propertyName)
        {
            this.Log.LogMessage(MessageType.INFORMATION, $"Getting DOM proprty '{propertyName}' for lazy element '{this.userFriendlyName}'");

            return(GenericWait.Wait(
                       () =>
            {
                return this.GetElement(this.GetRawExistingElement).GetDomProperty(propertyName);
            },
                       this.WaitTime(),
                       this.TimeoutTime()));
        }
コード例 #30
0
        /// <summary>
        /// Gets the representation of an element's shadow root for accessing the shadow DOM of a web component.
        /// </summary>
        /// <returns>A shadow root representation.</returns>
        public ISearchContext GetShadowRoot()
        {
            this.Log.LogMessage(MessageType.INFORMATION, $"Getting shadow root for lazy element '{this.userFriendlyName}'");

            return(GenericWait.Wait(
                       () =>
            {
                return this.GetElement(this.GetRawExistingElement).GetShadowRoot();
            },
                       this.WaitTime(),
                       this.TimeoutTime()));
        }