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

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

Selenium Error: "unrecognized proxy type: MANUAL"

问题

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

  1. from selenium import webdriver
  2. PROXY = "<HOST:PORT>"
  3. webdriver.DesiredCapabilities.FIREFOX['proxy'] = {
  4. "httpProxy": PROXY,
  5. "ftpProxy": PROXY,
  6. "sslProxy": PROXY,
  7. "proxyType": "MANUAL",
  8. }
  9. with webdriver.Firefox() as driver:
  10. 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:

  1. from selenium import webdriver
  2. PROXY = &quot;&lt;HOST:PORT&gt;&quot;
  3. webdriver.DesiredCapabilities.FIREFOX[&#39;proxy&#39;] = {
  4. &quot;httpProxy&quot;: PROXY,
  5. &quot;ftpProxy&quot;: PROXY,
  6. &quot;sslProxy&quot;: PROXY,
  7. &quot;proxyType&quot;: &quot;MANUAL&quot;,
  8. }
  9. with webdriver.Firefox() as driver:
  10. 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 即可消除下面的异常:

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

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

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

参考下面的代码:

  1. from selenium import webdriver
  2. PROXY = "<HOST:PORT>"
  3. webdriver.DesiredCapabilities.FIREFOX['proxy'] = {
  4. "httpProxy": PROXY,
  5. "sslProxy": PROXY,
  6. "proxyType": "manual",
  7. }
  8. with webdriver.Firefox() as driver:
  9. driver.get("https://selenium.dev")
英文:

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

  1. Message: Invalid proxyType value: MANUAL

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

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

Refer code below:

  1. from selenium import webdriver
  2. PROXY = &quot;&lt;HOST:PORT&gt;&quot;
  3. webdriver.DesiredCapabilities.FIREFOX[&#39;proxy&#39;] = {
  4. &quot;httpProxy&quot;: PROXY,
  5. &quot;sslProxy&quot;: PROXY,
  6. &quot;proxyType&quot;: &quot;manual&quot;,
  7. }
  8. with webdriver.Firefox() as driver:
  9. 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:

确定