selenium-Fresh browser per test


title: “Fresh browser per test”
weight: 9

Start each test from a clean known state.
Ideally, spin up a new virtual machine for each test.
If spinning up a new virtual machine is not practical,
at least start a new WebDriver for each test.
For Firefox, start a WebDriver with your known profile.

FirefoxProfile profile = new FirefoxProfile(new File("pathToFirefoxProfile"));
WebDriver driver = new FirefoxDriver(profile);

官方链接为:/documentation/test_practices/encouraged/fresh_browser_per_test/