Selenium webdriver Firefox使用webrequest验证代理
我正在尝试使用带有私有代理的firefox运行Selenium测试。 我在代理身份验证方面遇到问题。 没有Selenium webdriver Firefox使用webrequest验证代理,selenium-webdriver,firefox,proxy,selenium-firefoxdriver,proxy-authentication,Selenium Webdriver,Firefox,Proxy,Selenium Firefoxdriver,Proxy Authentication,我正在尝试使用带有私有代理的firefox运行Selenium测试。 我在代理身份验证方面遇到问题。 没有headless模式,我可以用Java中的Robot对代理进行身份验证。 现在,我想在firefox中以headless模式运行。 我用https://stackoverflow.com/questions/55522874/how-to-handle-proxy-authentication-in-firefox-with-self-created-extension-using但这不适合
headless
模式,我可以用Java中的Robot
对代理进行身份验证。
现在,我想在firefox中以headless
模式运行。
我用https://stackoverflow.com/questions/55522874/how-to-handle-proxy-authentication-in-firefox-with-self-created-extension-using
但这不适合我
我的代码:
background.js:
扩展文件似乎有错误
var config = {
mode: "fixed_servers",
rules: {
singleProxy: {
scheme: "http",
host: "xx.xx.xx.xx",
port: parseInt("xxxxx")
},
bypassList: []
}
};
firefox.proxy.settings.set({value: config, scope: "regular"}, function() {});
function callbackFn(details) {
return {
authCredentials: {
username: "xxxxx",
password: "xxxxx"
}
};
}
firefox.webRequest.onAuthRequired.addListener(
callbackFn,
{urls: ["<all_urls>"]},
['blocking']
);
{
"version": "1.0.0",
"manifest_version": 2,
"name": "Firefox Proxy | (Proxy Connector)",
"permissions": [
"proxy",
"tabs",
"unlimitedStorage",
"storage",
"<all_urls>",
"webRequest",
"webRequestBlocking"
],
"background": {
"scripts": ["background.js"]
}
}