Java 将我的驱动程序实例列为静态的最佳实践,特别是对于双重测试执行?

Java 将我的驱动程序实例列为静态的最佳实践,特别是对于双重测试执行?,java,selenium,selenium-webdriver,webdriver,Java,Selenium,Selenium Webdriver,Webdriver,将我的驱动程序实例列为静态实例的最佳实践,特别是对于双重测试执行? 驱动程序工厂(用于设置驱动程序实例): } 步骤类:(黄瓜步骤类): } 基本页面(页面对象的基本页面): }问题是什么?@sen4ik,如果我将webdriver变量设置为非静态,那么并行测试执行是否可能?是的,它肯定是可能的。在我的例子中,我使用WebDriver工厂。你可以在这里@sen4ik阅读,谢谢你的链接 public class DriverFactory { public static WebDriver dr

将我的驱动程序实例列为静态实例的最佳实践,特别是对于双重测试执行?

驱动程序工厂(用于设置驱动程序实例):

}

步骤类:(黄瓜步骤类):

}

基本页面(页面对象的基本页面):


}

问题是什么?@sen4ik,如果我将webdriver变量设置为非静态,那么并行测试执行是否可能?是的,它肯定是可能的。在我的例子中,我使用WebDriver工厂。你可以在这里@sen4ik阅读,谢谢你的链接
public class DriverFactory  {
public static WebDriver driver;
protected BasePage basePage;
protected LoginPage loginPage;


public WebDriver getDriver() throws Exception {
    try {
        ReadConfigFile file = new ReadConfigFile();
        String browserName = file.getBrowser();

        switch (browserName) {

        //firefox setup
        case "firefox":
            if (null == driver) {
                System.setProperty("webdriver.gecko.driver", Constant.GECKO_DRIVER_DIRECTORY);
                DesiredCapabilities capabilities=DesiredCapabilities.firefox();
                capabilities.setCapability("marionette", true);
                driver = new FirefoxDriver();
            }
            break;
            }
        }
    }
public class LoginSteps extends DriverFactory {

@Given("^User navigates to the \"([^\"]*)\" website$")
public void user_navigates_to_the_website(String url) throws Throwable {
    BasePage basePage = new BasePage();
    basePage.loadUrl(url);
}
public class BasePage extends DriverFactory {
protected WebDriverWait wait;
protected JavascriptExecutor jsExecutor;

public BasePage() throws IOException {
    this.wait = new WebDriverWait(driver, 15);
    jsExecutor = ((JavascriptExecutor) driver);
}