嗨,我有以下设置与我当前的框架,
ClassA
{
//Which Receives Selenium WebDriver call the 'driver' object reference to manipulate the locators in UI
public WebDriver get()
{
return MainClass.driver;
}
}
MainClass
{
public static Webdriver driver;
method A()
{
//which uses Firefox instance and it is passed to ClassA to operate
driver = new FirefoxDriver();
}
methodB()
{
//which creates new instance of Chrome
driver = new ChromeDriver();
}
}
我想要做的是,一旦我调用 methodB(),就会创建 Chrome 的实例,但是一旦完成,我想恢复到在 chrome 运行之前可用或调用的 firefox 实例,但是使用我的方法,因为我指的是相同的webdriver 对象旧的 Firefox 引用被删除。
有什么建议么 ?
PS:请原谅我遵循的不良代码约定