Selenium错误: “未识别的代理类型: MANUAL”

huangapple go评论104阅读模式
英文:

Selenium Error: "unrecognized proxy type: MANUAL"

问题

我正在尝试学习如何使用代理服务器运行Selenium WebDriver,但直接按照提供的代码文档进行操作:

from selenium import webdriver

PROXY = "<HOST:PORT>"
webdriver.DesiredCapabilities.FIREFOX['proxy'] = {
"httpProxy": PROXY,
"ftpProxy": PROXY,
"sslProxy": PROXY,
"proxyType": "MANUAL",

}

with webdriver.Firefox() as driver:
    driver.get("https://selenium.dev")

会产生以下错误:

selenium.common.exceptions.InvalidArgumentException: Message: Invalid proxyType value: MANUAL

文档是否已过时,还是我还有其他方面需要考虑?

有关相关文档,请查看此链接

英文:

I'm trying to learn how to run a selenium webdriver with a proxy server, but directly following the documentation with the provided code:

from selenium import webdriver

PROXY = &quot;&lt;HOST:PORT&gt;&quot;
webdriver.DesiredCapabilities.FIREFOX[&#39;proxy&#39;] = {
&quot;httpProxy&quot;: PROXY,
&quot;ftpProxy&quot;: PROXY,
&quot;sslProxy&quot;: PROXY,
&quot;proxyType&quot;: &quot;MANUAL&quot;,

}

with webdriver.Firefox() as driver:
    driver.get(&quot;https://selenium.dev&quot;)

yields the following error:

> selenium.common.exceptions.InvalidArgumentException: Message: Invalid proxyType value: MANUAL

Is the documentation outdated or is there something else I'm not taking into account here?

The documentation in question can be found here

答案1

得分: 0

将值从 MANUAL 更改为 manual 即可消除下面的异常:

Message: 无效的代理类型值: MANUAL

如果出现以下异常,请删除此行 &quot;ftpProxy&quot;: PROXY,

Message: SessionNotCreatedError: InvalidArgumentError: 自从 Firefox 90 起 'ftpProxy' 不再受支持

参考下面的代码:

from selenium import webdriver

PROXY = "<HOST:PORT>"
webdriver.DesiredCapabilities.FIREFOX['proxy'] = {
"httpProxy": PROXY,
"sslProxy": PROXY,
"proxyType": "manual",
}

with webdriver.Firefox() as driver:
    driver.get("https://selenium.dev")
英文:

By changing the value from MANUAL to manual you can get rid of below exception

Message: Invalid proxyType value: MANUAL

And if you get below exception then remove this line &quot;ftpProxy&quot;: PROXY,.

Message: SessionNotCreatedError: InvalidArgumentError: Since Firefox 90 &#39;ftpProxy&#39; is no longer supported

Refer code below:

from selenium import webdriver

PROXY = &quot;&lt;HOST:PORT&gt;&quot;
webdriver.DesiredCapabilities.FIREFOX[&#39;proxy&#39;] = {
&quot;httpProxy&quot;: PROXY,
&quot;sslProxy&quot;: PROXY,
&quot;proxyType&quot;: &quot;manual&quot;,
}

with webdriver.Firefox() as driver:
    driver.get(&quot;https://selenium.dev&quot;)

huangapple
  • 本文由 发表于 2023年6月15日 15:20:51
  • 转载请务必保留本文链接:https://go.coder-hub.com/76480040.html
匿名

发表评论

匿名网友

:?: :razz: :sad: :evil: :!: :smile: :oops: :grin: :eek: :shock: :???: :cool: :lol: :mad: :twisted: :roll: :wink: :idea: :arrow: :neutral: :cry: :mrgreen:

确定