*/
@SuppressWarnings("unchecked")
@Override
public void destroyInstance(WebDriver instance) {
@SuppressWarnings("rawtypes")
Destructor destructor = null;
// get destructor which is able to handle RemoteReusable logic if set
if (instance instanceof ReusableRemoteWebDriver) {
destructor = getRemoteWebDriverDestructor();
}
else {
try {
destructor = registryInstance.get().getEntryFor(instance.getClass(), Destructor.class);
} catch (Exception ignored) {
log.log(Level.WARNING,
"Unable to get destructor for @Drone WebDriver, real class {0}, quitting instance using default disposal method",
instance.getClass().getSimpleName());
}
}
if (destructor != null && !destructor.getClass().equals(this.getClass())) {
destructor.destroyInstance(instance);
}
// this is default destructor
else {
instance.quit();
}