我想测试一个 Chrome 扩展程序并对其进行测试,我需要让它随机浏览网页并长时间访问随机页面,看看它是否会产生任何错误。您需要登录扩展程序,这就是为什么我没有为此使用 Selenium,因为我找不到使用 Selenium 登录扩展程序的方法。
有没有办法让 Selenium 作用于现有或预设的 Chrome 存在?还有其他选择吗?
我想测试一个 Chrome 扩展程序并对其进行测试,我需要让它随机浏览网页并长时间访问随机页面,看看它是否会产生任何错误。您需要登录扩展程序,这就是为什么我没有为此使用 Selenium,因为我找不到使用 Selenium 登录扩展程序的方法。
有没有办法让 Selenium 作用于现有或预设的 Chrome 存在?还有其他选择吗?
您可以使用网络分机。您可以使用 Firefox、谷歌 Chrome、Chromium。
您可以像这样编写浏览器脚本。
import webExt from 'web-ext';
webExt.cmd.run({
// These are command options derived from their CLI conterpart.
// In this example, --source-dir is specified as sourceDir.
firefox: '/path/to/Firefox-executable',
sourceDir: '/path/to/your/extension/source/',
}, {
// These are non CLI related options for each function.
// You need to specify this one so that your NodeJS application
// can continue running after web-ext is finished.
shouldExitProgram: false,
})
.then((extensionRunner) => {
// The command has finished. Each command resolves its
// promise with a different value.
console.log(extensionRunner);
// You can do a few things like:
// extensionRunner.reloadAllExtensions();
// extensionRunner.exit();
});
应该有一个选项来定义--start-url。您可以通过一些编程将其设为随机网址...现在无法对其进行测试,但您应该能够使其工作
或者你只是从命令行运行
web-ext run --start-url www.mozilla.com