Selenium WebDriver.get(url) 不打开 URL [英] Selenium WebDriver.get(url) does not open the URL
问题描述
from selenium import webdriver
from selenium.common.exceptions import TimeoutException
from selenium.webdriver.support.ui import WebDriverWait # available since 2.4.0
import time
# Create a new instance of the Firefox driver
driver = webdriver.Firefox()
# go to the google home page
driver.get("http://www.google.com")
这会打开 Firefox 窗口,但不会打开网址.
This opens a Firefox window but does not open a url.
- 我有一个代理服务器(但地址栏没有显示传递的 url)
- 我有两个 Firefox 配置文件.
1 或 2 会成为问题吗?如果是,那我该如何解决?
Can 1 or 2 be an issue? if yes, then how can I resolve it?
推荐答案
这是一个Selenium 缺陷一>.
我在代理后面的 Ubuntu 12.04 中遇到了同样的问题.
It is a defect of Selenium.
I have the same problem in Ubuntu 12.04 behind the proxy.
问题在于不正确的处理代理排除.默认 Ubuntu 排除位于 no_proxy 环境变量中:
Problem is in incorrect processing proxy exclusions. Default Ubuntu exclusions are located in no_proxy environment variable:
no_proxy=localhost,127.0.0.0/8
但似乎 /8 掩码对硒不起作用.要解决此问题,只需将 no_proxy 更改为以下内容即可:
But it seems that /8 mask doesn't work for selenium. To workaround the problem it is enough to change no_proxy to the following:
no_proxy=localhost,127.0.0.1
在运行 python 脚本之前删除代理设置也有帮助:
Removing proxy settings before running python script also helps:
http_proxy= python script.py
这篇关于Selenium WebDriver.get(url) 不打开 URL的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!