public static void inject(final WebDriver driver, final URL scriptUrl, Boolean skipFrames) {
		final String script = getContents(scriptUrl);

		if (!skipFrames) {
			final ArrayList<WebElement> parents = new ArrayList<WebElement>();
			injectIntoFrames(driver, script, parents);
		}

		JavascriptExecutor js = (JavascriptExecutor) driver;
		driver.switchTo().defaultContent();
		js.executeScript(script);
	}
public static void inject ( final WebDriver driver , final URL scriptUrl , Boolean skipFrames ) { final String script = getContents ( scriptUrl ) ; if ( ! skipFrames ) { final ArrayList < WebElement > parents = new ArrayList < WebElement > ( ) ; injectIntoFrames ( driver , script , parents ) ; } JavascriptExecutor js = ( JavascriptExecutor ) driver ; driver . switchTo ( ) . defaultContent ( ) ; js . executeScript ( script ) ; }
Recursively injects a script to the top level document with the option to skip iframes.
@param driver WebDriver instance to inject into
@param scriptUrl URL to the script to inject
@param skipFrames True if the script should not be injected into iframes