Hey Prashant, in Selenium Base class is the main class which takes care of Browser setup, loading configuration file and other reusable methods like screenshot, handling sync issues and many more. With base class you can avoid code duplication and can reuse the code as much you want. Base Class works with Selenium in following manner:
-
When we create base class and if TestCases extends BaseClass then we can use all the methods of Baseclass.
-
Before calling actual @Test, Base class methods will get executed and Depends on annotations it will call the respective methods.
-
We can extend this class in all test cases and we can call custom methods as well directly.