我如何在 Chrome 实例中随机浏览 Web,并使用登录的 Chrome 扩展程序?
How can I browse the web randomly in a Chrome instance with a logged in Chrome extension?
我想测试一个 Chrome 扩展,为了测试它,我需要让它随机浏览网页并长时间访问随机页面,看看它是否会产生任何错误。您需要登录扩展程序,这就是为什么我没有为此使用 Selenium 的原因,因为我找不到使用 Selenium 登录扩展程序的方法。
有没有办法让Selenium作用于现有的或预设的Chrome存在?还有其他选择吗?
您可以使用网络分机。您可以使用 Firefox、google 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。您可以通过一些编程使其成为随机 url...现在无法对其进行测试,但您应该能够使其工作
或者您只是 运行 从命令行
web-ext run --start-url www.mozilla.com
我想测试一个 Chrome 扩展,为了测试它,我需要让它随机浏览网页并长时间访问随机页面,看看它是否会产生任何错误。您需要登录扩展程序,这就是为什么我没有为此使用 Selenium 的原因,因为我找不到使用 Selenium 登录扩展程序的方法。
有没有办法让Selenium作用于现有的或预设的Chrome存在?还有其他选择吗?
您可以使用网络分机。您可以使用 Firefox、google 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。您可以通过一些编程使其成为随机 url...现在无法对其进行测试,但您应该能够使其工作
或者您只是 运行 从命令行
web-ext run --start-url www.mozilla.com