Using C# Extension methods for Selenium

In the last post we discussed working with custom library methods customization, we optimized the library code a lot, but still using C# Extension methods, we can optimize the code way beyond the way it look like earlier while we started discussing writing a custom library method post here

C# Extension methods

Extension methods enable you to “add” methods to existing types without creating a new derived type, recompiling, or otherwise modifying the original type. Extension methods are a special kind of static method, but they are called as if they were instance methods on the extended type.

For client code written in C# and Visual Basic, there is no apparent difference between calling an extension method and the methods that are actually defined in a type.

Our extension method hooks to IWebElement type and will look like this

Great Post. I wanted to know if it is possible to override the default Click(). I dont want to update my tests with a newly created method. I want that my method be called if I call the default Click().