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?

asked Mar 20, 2018 at 12:44
1
  • 2
    The exception event handler should be of type WebDriverExceptionEventArgs not WebElementEventArgs Commented 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);
}
answered Mar 20, 2018 at 14:42

Your Answer

Draft saved
Draft discarded

Sign up or log in

Sign up using Google
Sign up using Email and Password

Post as a guest

Required, but never shown

Post as a guest

Required, but never shown

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

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.