Suppose you have two classes:
Class1:
public class Class1 {
//Your code above
}
Class2:
public class Class2 {
}
You can use Class2 in different ways:
Class Field:
public class Class1{
private Class2 class2 = new Class2();
}
Method field:
public class Class1 {
public void loginAs(String username, String password)
{
Class2 class2 = new Class2();
class2.invokeSomeMethod();
//your code
}
}
Static methods from Class2 Imagine this is your Class2:
public class Class2 {
public static void doSomething(){
}
}
From class1 you can call Class2 :
public class Class1 {
public void loginAs(String username, String password)
{
Class2.doSomething();
//your code
}
}
I hope this helps!
Join Selenium training for more information!
Thanks!