@Override protected RemoteWebDriver extractRemoteWebDriver(WebDriver driver) { if (driver.getClass().isAnnotationPresent(Augmentable.class) || driver .getClass() .getName() .startsWith("org.openqa.selenium.remote.RemoteWebDriver$$EnhancerByCGLIB")) { return (RemoteWebDriver) driver; } else { logger.warning( "Augmenter should be applied to RemoteWebDriver instances " + "or previously augmented instances only"); return null; } }
private boolean driverCanTakeSnapshots() { if (driver == null) { return false; } else if (driver instanceof WebDriverFacade) { return ((WebDriverFacade) driver).canTakeScreenshots() && (((WebDriverFacade) driver).getProxiedDriver() != null); } else { return TakesScreenshot.class.isAssignableFrom(driver.getClass()); } }
private void savePageSourceFor(final String screenshotFile) throws IOException { if (WebDriver.class.isAssignableFrom(driver.getClass())) { try { WebDriver webdriver = driver; String pageSource = webdriver.getPageSource(); File savedSource = new File(sourceCodeFileFor(screenshotFile)); FileUtils.writeStringToFile(savedSource, pageSource); } catch (WebDriverException e) { getLogger().warn("Failed to save screen source code", e); } } }
public static boolean isMobile(WebDriver driver) { if (driver instanceof WebDriverFacade) { return ((WebDriverFacade) driver).getDriverClass().isAssignableFrom(AppiumDriver.class); } return (driver.getClass().isAssignableFrom(AppiumDriver.class)); }
public static WebDriver unwrap(WebDriver wrapped) { if (WrapsDriver.class.isAssignableFrom(wrapped.getClass())) { return unwrap(((WrapsDriver) wrapped).getWrappedDriver()); } else return wrapped; }
private boolean isAMock(WebDriver driver) { return driver.getClass().getCanonicalName().contains("Mock"); }