How can we cal an object selenium to the other file which has half code of selenium.
In PHP i can by following code.
login($this);
----> login
Replace:
public void testAllTests() throws Exception {
Library obj1 = new Library();
obj1.Login();
}
With:
public void testAllTests() throws Exception {
super.Login();
}
Since your Login class already extends Library it already has the Login() method present in it. What you are currently doing is creating a new Library object which does not run the @Before
and hence the Selenium field is not initialised (in the new object).
When a subclass extends a base class it will inherit its methods. This is a fundamental Java and OOP concept.