Class that contains all classes
public class AllTests{
public static void main(String[] args) {
Loginer.login();
Example.linkOne();
Examplee.linkTwo();
}
}
Class that starts the Firefox driver and logins
public class Loginer{
public static login(){
WebDriver driver = new FirefoxDriver();
driver.get("http://LINKISHERE.COM/");
//other login code
}
}
Actual Selenium code that clicks links and stuff
public class Example{
public static linkOne() {
**driver**.findElement(By.className("CLASSNAME")).click();
}
public static linkTwo() {
**driver**.findElement(By.className("CLASSNAME")).click();
}
}
I'm pretty new to JAVA, I only worked with python till now.
What I'm trying to do is have multiple tests split into multiple classes that are part of the AllTests class, so I can take them out or add new ones with easy.
My trouble has been using the same WebDriver in all classes due to this java.lang.NullPointerException. Is this recommended or should it be fine to have Selenium start a new WebDriver every time?