I have my own CustomDriver
which extends ChromeDriver
.
public CustomDriver extends ChromeDriver
For some need I am wrapping the CustomDriver inside the EventFiringWebDriver
.Everything is working fine . but when I try to unwrap the underneath Driver inside the EventFiringWebDriver I get the below exception.
java.lang.ClassCastException: com.sun.proxy.$Proxy14 cannot be cast to com.test.CustomDriver.
Below is the Code which I am trying to Unwrap my Driver.
private CustomDriver extract(EventFiringWebDriver wd) {
return (CustomDriver) wd.getWrappedDriver();
}
Can anybody please help, Is this a bug with Selenium 2.0 or its the desired feature, If yes then how can I achive it.
I could achive it in this way. It is not important for me that what eventually EventFiringWebDriver does with the proxy Object.
public class EventFiringWebDriverWrapper extends EventFiringWebDriver {
private WebDriver driver;
public EventFiringWebDriverWrapper(WebDriver driver) {
super(driver);
this.driver= driver;
}
@Override
public WebDriver getWrappedDriver() {
return driver;
}
}
And I can extract it this way, which is good to go
private CustomDriver extract(EventFiringWebDriverWrapper wd) {
return (CustomDriver) wd.getWrappedDriver();
}