如何解决如何在selenium脚本中获取firefox扩展背景页面
我在 selenium 中工作。 我有我的浏览器扩展程序,我临时安装在 firefox(开发人员)中。如何获取后台页面(即后台脚本)以便我可以将其用于测试?
例如,在 puppeteer 中,您可以通过以下方式执行此操作:
const puppeteer = require('puppeteer');
(async () => {
const pathToExtension = require('path').join(__dirname,'my-extension');
const browser = await puppeteer.launch({
headless: false,args: [
`--disable-extensions-except=${pathToExtension}`,`--load-extension=${pathToExtension}`
]
});
const targets = await browser.targets();
const backgroundPageTarget = targets.find(target => target.type() === 'background_page');
const backgroundPage = await backgroundPageTarget.page();
// Test the background page as you would any other page.
await browser.close();
})();
所以我特别指的是这些行:
const backgroundPageTarget = targets.find(target => target.type() === 'background_page');
const backgroundPage = await backgroundPageTarget.page();
有没有类似的方法可以为硒做到这一点? 我需要访问它,以便我可以将它用于我的 mocha 测试。
谢谢
版权声明:本文内容由互联网用户自发贡献,该文观点与技术仅代表作者本人。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌侵权/违法违规的内容, 请发送邮件至 dio@foxmail.com 举报,一经查实,本站将立刻删除。