![](/img/trans.png)
[英]Webdriver.io/Selenium tests fail when the window is in the background on Chrome 87
[英]Is there any way to run webdriver.io selenium tests against a chrome extension?
我在想一些类似的事情
capabilities: [
{
maxInstances: 1,
browser: "Chrome",
name: "Chrome"
},
{
maxInstances: 1,
browser: "Chrome",
options: "myIeExtension",
name: "IE"
}
]
名称位是可选的,但非常方便。
编辑:目前我有
const fs = require('fs');
function encode(file) {
const stream = fs.readFileSync(file);
return Buffer.from(stream).toString('base64');
}
capabilities: [
{
maxInstances: 1,
browserName: 'chrome',
chromeOptions: { extensions: [encode('path_to_my_crx_file/my_extension.crx')] },
}
],
可以,但是每次运行硒测试时,我都必须通过扩展名简介-输入电子邮件,密码,然后选择并启动。 是否有任何办法可以让硒输入所有这些值作为测试的一部分?
因此,您可以按照上述步骤在ChromeOptions中指定chrome扩展程序的路径。 但是,您必须每次都进行设置。
或者,只需使用默认配置文件:
capabilities: [
{
maxInstances: 1,
browserName: 'chrome',
chromeOptions: { args: ['user-data-dir=/home/<username>/.config/google-chrome'] },
},
您不必每次使用扩展程序时都进行设置,只需执行一次即可,然后就可以使用它了。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.