// are also instances of RemoteWebElement class. The only way that we found at the current moment to find out
// whether WebElement instance is on remote driver is to check the class of RemoteWebElement "parent" filed,
// which contains WebDriver instance to which this RemoteWebElement belongs.
// As this field has protected access this is done by reflection.
// TODO It's is a kind of a dirty hack to be improved in future versions.
RemoteWebElement remoteWebElement = (RemoteWebElement) element;
try {
Field elementParentFiled = RemoteWebElement.class.getDeclaredField("parent");
elementParentFiled.setAccessible(true);
WebDriver elementParent = (WebDriver) elementParentFiled.get(remoteWebElement);
return elementParent.getClass().equals(RemoteWebDriver.class);