有什么方法可以实现本地实例的类型 转换WebDriver
到??? 我的代码是这样的ThreadLocal<WebDriver>
MarionetteDriver
public class Base_Class
{
protected ThreadLocal<WebDriver> Driver = null;
@BeforeMethod
@Parameters("BrowserName")
public void setUp(@Optional("Firefox") String BrowserName) throws MalformedURLException
{
Driver = new ThreadLocal<WebDriver>();
if(BrowserName.equalsIgnoreCase("FireFox"))
{
System.setProperty("webdriver.gecko.driver", "..//BrowserDrivers//wires");
DesiredCapabilities capabilities = DesiredCapabilities.firefox();
capabilities.setCapability("marionette", true);
Driver = new <ThreadLocal<WebDriver>> MarionetteDriver(capabilities);
}
else if(BrowserName.equalsIgnoreCase("Chrome"))
{
System.setProperty("webdriver.chrome.driver", "..//BrowserDrivers//chromedriver");
Driver = new <ThreadLocal<WebDriver>>ChromeDriver();
}
}
public WebDriver getDriver()
{
return Driver.get();
}
@AfterMethod
public void closeBrowser()
{
getDriver().quit();
}
}
并且所有测试用例都定义在单独的类中,这些类扩展了 Base_Class。
得到错误@
Driver = new <ThreadLocal<WebDriver>> MarionetteDriver(capabilities); and Driver = new <ThreadLocal<WebDriver>>ChromeDriver(); lines as Type mismatch: cannot convert from MarionetteDriver to ThreadLocal<WebDriver>
我在操作系统上使用Chrome Version 52.0.2743.116 (64-bit)
和FireFox Version 48.0
版本浏览Ubuntu 14.04
器Selenium version selenium-server-standalone-2.53.0
想通过testng.xml
文件实现并行测试执行..
任何帮助将不胜感激..