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"); } } }
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"); } } }
/// <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()); }
/// <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); })); }
/// <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"); })); }
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); }
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); }
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); }
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"); }
/// <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); }); }
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()); }
/// <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); }); }
/// <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); }); }
/// <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; })); }
/// <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); }); }
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"); }
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); }
public void WaitUntilTimeoutReturnsTrue() { var result = GenericWait.WaitUntilTimeout( () => true, TimeSpan.FromSeconds(1), TimeSpan.FromSeconds(2), false); Assert.IsTrue(result, "Expected Wait to return true"); }
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"); }
/// <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)); }
/// <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)); }
/// <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)); }
/// <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)); }
/// <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())); }
/// <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())); }
/// <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())); }
/// <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())); }
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"); }
/// <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())); }
/// <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())); }