1

When i run tests with https headless, the error below shows up

bash Error: move target out of bounds: Failed to read the 'localStorage' property from 'Window': Access is denied for this document.

Running without --headless option, it works but slower. Running as http with --headless works too

  • CodeceptJS version: newest
  • NodeJS Version:4.2.6
  • Operating System: Mint
  • WebDriverIO: newest
  • Configuration file:

```json

{
  "tests": "./**/*_test.js",
  "timeout": 10000,
  "output": "output",
  "helpers": {
    "WebDriverIO": {
      "smartWait": 50,
      "url": "https://172.17.0.1/",
      "browser": "chrome",
      "restart": false,
      "desiredCapabilities": {
        "chromeOptions": {
          "args":[
                  "--window-size=1200,1200",
                  "--headless"]
        }
      }
    }
  },
  "include": {
    "I": "./steps_file.js",
    "loginPage": "./pages/Login.js",
    "defaultData": "./Data/defaultData.js",
    "registerPage": "./pages/Register.js",
    "menu": "./pages/Menus.js",
    "profilePage": "./pages/Profile.js",
    "subscription": "./pages/Subscription.js",
    "recordsPage": "./pages/Records.js"
  },
  "bootstrap": true,
  "name": "CodeceptJS",
  "plugins": {
    "allure": {
      "enabled": "true"    }
  }
}

```

Matheus Souza
  • 55
  • 1
  • 6

2 Answers2

1

Try using an x instead of a comma (,) when specifying the window size. Example:

--window-size=1920x1080
Michael Cox
  • 747
  • 8
  • 19
0

Maybe this is related to this:

https://www.chromium.org/for-testers/bug-reporting-guidelines/uncaught-securityerror-failed-to-read-the-localstorage-property-from-window-access-is-denied-for-this-document

You could create Chrome profile where you will turn off this option and load it by providing run parameter (https://chromium.googlesource.com/chromium/src/+/HEAD/docs/user_data_dir.md):

"chromeOptions": {
      "args":[
              "--window-size=1200,1200",
              "--headless",
              "--user-data-dir=<YOURDIR>]
    }

Another solution you could check if UserAgent string for headless is different than normal browser, and if answer is yes override it with (Chrome 69 UA):

    "chromeOptions": {
      "args":[
              "--window-size=1200,1200",
              "--headless",
              "--user-agent="Mozilla/5.0 AppleWebKit (KHTML, like Gecko) Chrome/69.0 Safari"]
    }

And the last one is to turn off security policy by providing parameters:

  • --disable-web-security
  • --allow-running-insecure-content

    "chromeOptions": {
      "args":[
              "--window-size=1200,1200",
              "--headless",
              "--disable-web-security",
              "--allow-running-insecure-content"]
    }
    

You can try one of the possible solutions or combine them.

jadupl
  • 210
  • 3
  • 15