Selenium 使用https的Codeceptjs无头测试不起作用
当我使用https headless运行测试时,下面的错误显示出来Selenium 使用https的Codeceptjs无头测试不起作用,selenium,webdriver-io,codeceptjs,Selenium,Webdriver Io,Codeceptjs,当我使用https headless运行测试时,下面的错误显示出来 bash 错误:将目标移出边界:未能从“窗口”读取“localStorage”属性:拒绝对此文档的访问。 在没有--headless选项的情况下运行,它可以工作,但速度较慢。 使用--headless作为http运行也可以 CodeceptJS版本:最新 NodeJS版本:4.2.6 操作系统:Mint WebDriverIO:最新 配置文件: ```json { "tests": "./**/*_test.js",
bash
错误:将目标移出边界:未能从“窗口”读取“localStorage”属性:拒绝对此文档的访问。
在没有--headless选项的情况下运行,它可以工作,但速度较慢。
使用--headless作为http运行也可以
- CodeceptJS版本:最新
- NodeJS版本:4.2.6
- 操作系统:Mint
- WebDriverIO:最新
- 配置文件:
{
"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" }
}
}
```在指定窗口大小时,尝试使用
x
而不是逗号(,
)。
例如:
也许这与此有关: 您可以创建Chrome配置文件,在其中关闭此选项并通过提供run参数()加载它: 最后一个是通过提供参数关闭安全策略:
- --禁用web安全
- --允许运行不安全的内容
"chromeOptions": { "args":[ "--window-size=1200,1200", "--headless", "--disable-web-security", "--allow-running-insecure-content"] }
您可以尝试其中一种可能的解决方案,也可以将它们结合起来。这不是问题所在:/
"chromeOptions": {
"args":[
"--window-size=1200,1200",
"--headless",
"--user-data-dir=<YOURDIR>]
}
"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"]
}