当我使用https headless运行测试时,出现以下错误
bash
Error: move target out of bounds: Failed to read the 'localStorage' property from 'Window': Access is denied for this document.
不带--headless选项运行,可以运行,但速度较慢。 也可以通过--headless与http一起运行
```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" }
}
}
```
答案 0 :(得分:1)
在指定窗口大小时,请尝试使用x
而不是逗号(,
)。
示例:
--window-size=1920x1080
答案 1 :(得分:0)
也许与此有关:
您可以创建Chrome配置文件,然后通过提供运行参数(https://chromium.googlesource.com/chromium/src/+/HEAD/docs/user_data_dir.md)来关闭此选项并进行加载:
"chromeOptions": {
"args":[
"--window-size=1200,1200",
"--headless",
"--user-data-dir=<YOURDIR>]
}
另一种解决方案,您可以检查无头的UserAgent字符串是否与普通浏览器不同,如果答案为是,请使用(Chrome 69 UA)覆盖它:
"chromeOptions": {
"args":[
"--window-size=1200,1200",
"--headless",
"--user-agent="Mozilla/5.0 AppleWebKit (KHTML, like Gecko) Chrome/69.0 Safari"]
}
最后一个是通过提供参数来关闭安全策略:
-允许运行不安全的内容
"chromeOptions": {
"args":[
"--window-size=1200,1200",
"--headless",
"--disable-web-security",
"--allow-running-insecure-content"]
}
您可以尝试一种可能的解决方案或将其组合。