Reputation: 191
I've subscribed to the Navigated and Navigating events of the WebDriver but the events are not triggered. What's their use if they do not work? Is there something additional that I need to do in order for them to get triggered?
_driver = new PhantomJSDriver();
EventFiringWebDriver eventDriver = new EventFiringWebDriver(_driver);
eventDriver.Navigating += navigatedHandler;
_driver.Navigate().GoToUrl(yt);
private void navigatedHandler(object sender, WebDriverNavigationEventArgs args)
{
MessageBox.Show("navigating");
}
Upvotes: 1
Views: 806
Reputation: 27486
You've circumvented the event mechanism by navigating using your initial IWebDriver
object. Calling the methods on the EventFiringWebDriver
instance will properly fire the events. In the case of your example code:
_driver = new PhantomJSDriver();
EventFiringWebDriver eventDriver = new EventFiringWebDriver(_driver);
eventDriver.Navigating += navigatingHandler;
// This line changes. Use eventDriver instead of _driver to navigate.
eventDriver.Navigate().GoToUrl(yt);
Upvotes: 2