How to implement WebDriverEventListener in C#?
I have no problem doing it in java importing:
import org.openqa.selenium.support.events.A
Event listening in the C# is accomplished by using the standard event mechanism exposed by the language. You create a method with the correct signature for the event, and attach it to the event. An example method would look like this:
void MyElementClickedHandler(object sender, WebElementEventArgs e)
{
Console.WriteLine("Clicked");
}
Attaching the event would look something like this:
// Assumes driver is a properly created
// IWebDriver instance.
IWebDriver eventDriver = new EventFiringWebDriver(driver);
eventDriver.ElementClicked += new EventHandler(MyElementClickedHandler);
Inside the event handler method, the EventArgs parameter allows you to examine attributes associated with the event. In the case of an element event, the EventArgs will have a reference to the IWebElement the event fired on. To disconnect the event handler, you use the standard C# -= operator.