量角器/硒嵌入式凭据放弃了对chrome的支持 [英] Protractor/Selenium embedded credentials dropped support for chrome
问题描述
我目前正在通过一些身份验证来管理登台环境.
I am currently managing a staging environment with some authentication.
我能够通过将凭据嵌入到URL中来运行测试,如下所示:
I was able to run my tests by embedding credentials to URL like this:
https://johndoe:foobar@app.s.product.com/#login
但是,我的测试由于chrome而失败,因此删除了此功能( https://www.chromestatus.com/feature/5669008342777856 ).我还有其他方法可以访问我们的登台站点吗?我尝试检查弹出窗口中的凭据,也许我可以sendKeys(),但无济于事.
However, my tests fail because of chrome, dropping this feature(https://www.chromestatus.com/feature/5669008342777856). Is there any other way I can access our staging site? I tried inspecting the popup for credentials and maybe I can sendKeys(), but to no avail.
提前谢谢!
推荐答案
也存在此问题.我的解决方案是创建chrome扩展程序,并在启动时将其添加到chrome中.
Have this problem too. My solution is creation chrome extension and add it to chrome on startup.
- 在某些新文件夹中创建两个文件:
background.js (用您的用户更改用户和路径)
background.js (change user and path with yourth)
chrome.webRequest.onAuthRequired.addListener(
function(details, callbackFn) {
console.log("onAuthRequired!", details, callbackFn);
callbackFn({
authCredentials: {username: "user", password: "pass"}
});
},
{urls: ["<all_urls>"]},
['asyncBlocking']
);
manifest.json
{
"manifest_version": 2,
"name": "Authentication for tests",
"version": "1.0.0",
"permissions": ["<all_urls>", "webRequest", "webRequestBlocking"],
"background": {
"scripts": ["background.js"]
}
}
-
将它们打包为crx(chrome://extensions/->扩展包)
Pack them into crx (chrome://extensions/ -> Pack extension)
将此文件添加到项目中
添加到conf.js:
Add to conf.js:
作为第一行
var fs = require('fs');
const ext64 = fs.readFileSync('./ext.crx', 'base64');
exports.config = {
...
和镀铬选项
capabilities: {
browserName: 'chrome',
chromeOptions: {
args: ['--no-sandbox'],
extensions: [ext64]
}
},
这篇关于量角器/硒嵌入式凭据放弃了对chrome的支持的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!