I am using Selenium with Java and Chrome/Firefox driver.
FirefoxProfile profile = new FirefoxProfile();
profile.setPreference("javascript.enabled", true);
profile.setPreference("security.fileuri.strict_origin_policy", false);
DesiredCapabilities capabilities = DesiredCapabilities.firefox();
capabilities.setCapability(FirefoxDriver.PROFILE, profile);
capabilities.setCapability(CapabilityType.ACCEPT_SSL_CERTS, true);
capabilities.setCapability("acceptInsecureCerts",true);
FirefoxOptions options = new FirefoxOptions();
options.addCapabilities(capabilities);
WebDriver webDriver = new FirefoxDriver(options);
Trying to read the CSS stylesheet
JavascriptExecutor js = ((JavascriptExecutor) driver);
Object properties = js.executeScript("return document.styleSheets");
I get the following error:
Exception in thread "main" org.openqa.selenium.WebDriverException: SecurityError: CSSStyleSheet.cssRules getter: Not allowed to access cross-origin stylesheet
With a chrome driver I get the error error reading property
.
I am trying to get the document.styleSheets
of a page, but I can't because of CORS rules. How to disable them?