So, the problem is next: I have a class that is responsible for WebDriver. Every WebDriver object is a Singletone so, I use ThreadLocal for use this driver in many tests.
private static final ThreadLocal<WebDriver> threadLocalScope = new ThreadLocal<WebDriver>() {
@Override
protected WebDriver initialValue() {
ConfigProperty configProperty = new ConfigProperty();
System.setProperty(configProperty.getChromeDriver(), configProperty.getUrl());
ChromeOptions options = new ChromeOptions();
options.addExtensions(new File(configProperty.getChromeExtension()));
driver = new ChromeDriver(options);
driver.manage().window().maximize();
return driver;
}
};
public static WebDriver getDriver() {
return threadLocalScope.get();
}
As you can see, when the driver start it install some extension for Google Chrome, but not in each test this extension is necessary.
So, I wont to create an Annotation something like @InstallExtension, and in runtime see for this. If annotation is present under my test it will install for WebDriver this extension, in other way - not. How can I do it?
Aucun commentaire:
Enregistrer un commentaire