1

I am encountering a problem trying to use WebDriverExceptionEventArgs.ThrownException:

firingWebDriver.ExceptionThrown     += new EventHandler<WebElementEventArgs>(_ExceptionThrown);

static void _ExceptionThrown(object sender, WebElementEventArgs e)
    {
        //System.Diagnostics.Trace.WriteLine(e.ThrownException.Message);
        //Console.WriteLine(e.ThrownException.Message);
    }

However VS2015 displays the following error:

Cannot implicitly convert type 'System.EventHandler<OpenQA.Selenium.Support.Events.WebElementArgs> to 'System.EventHandler<OpenaQA.Selenium.Support.Events.WebDriverExceptionEventArgs>

I am not sure where the mistake lies, any help?

1
  • 2
    The exception event handler should be of type WebDriverExceptionEventArgs not WebElementEventArgs
    – Kate Paulk
    Mar 20, 2018 at 13:27

1 Answer 1

0

As Kate Paulk commented, the solution was to change WebElementEventArgs to WebDriverExceptionEventArgs, like so:

firingWebDriver.ExceptionThrown     += new EventHandler<WebDriverExceptionEventArgs>(_ExceptionThrown);

static void _ExceptionThrown(object sender, WebDriverExceptionEventArgs e)
{
    //System.Diagnostics.Trace.WriteLine(e.ThrownException.Message);
    //Console.WriteLine(e.ThrownException.Message);
}

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.