Created
May 29, 2019 15:05
-
-
Save elgatov/c566736afc163c0cda45489433c477e9 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
using OpenQA.Selenium; | |
using OpenQA.Selenium.Support.Events; | |
using OpenQA.Selenium.Support.UI; | |
using System; | |
namespace InfrastructureSelenium.Helper | |
{ | |
class EventFiringWebDriverWait : WebDriverWait | |
{ | |
private event EventHandler<WebDriverExceptionEventArgs> TimedOut; | |
private IWebDriver driver { get; set; } | |
public EventFiringWebDriverWait(IWebDriver driver, TimeSpan timeout) : base(driver, timeout) | |
{ | |
this.driver = driver; | |
TimedOut = new EventHandler<WebDriverExceptionEventArgs>(EventListeners._ExceptionThrown); | |
IgnoreExceptionTypes(typeof(NotFoundException)); | |
Message = "El elemento no ha sido encontrado en el tiempo límite. Finalizando ejecución"; | |
} | |
protected override void ThrowTimeoutException(string exceptionMessage, Exception lastException) | |
{ | |
EventHandler<WebDriverExceptionEventArgs> handler = TimedOut; | |
handler(this, new WebDriverExceptionEventArgs(driver, | |
new WebDriverTimeoutException(Message, lastException)) | |
); | |
} | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment