My question is as follows: How can I reuse a browser session for tests that are in different java classes? I have the browser open like this:
public class OpenBr
You should check with QMetry Automation framework it provides driver management through TestBase. You don't need to create driver instance, just configure in property or xml configuration file and use driver in any class using 'getDriver()' call.
WebDriver driver = WebDriverTestBase.getDriver();
It also has different design concepts like TestPage, TestStep, DataBean, Locator Repository, Data-Driven Testing Listeners and many more.
In order to configure driver, you can set property driver.name
outside the code with driver name like
driver.name=firefoxDriver
If you want to run on multiple browser in parallel you can provide driver in xml configuration file like:
In above example, it will run all test in my.pkg
parallel in two different browsers. You don't need to create or quite driver object in your code.
It also has mechanism to retry if driver creation fail, which is quite useful when you are running test on cloud.