Selenium webdriver.get()方法并不总是有效

时间:2018-05-23 23:25:39

标签: python python-3.x selenium selenium-webdriver selenium-chromedriver

link = "https://www.google.com"
chrome_options = webdriver.ChromeOptions()
chrome_options.add_argument('--proxy-server=%s' % str(xxx))
chrome = webdriver.Chrome(chrome_options=chrome_options)
time.sleep(3)
chrome.get(link)
print("po get")
time.sleep(1)
chrome.get(link)
time.sleep(15)

你好,我有很长一段时间的硒问题,我想找到一种方法来解决它 问题是几乎每次我运行一个打开selenium的脚本/甚至当我使用它时 对于测试,例如:

from selenium import webdriver
chrome = webdriver.Chrome()
chrome.get(https://www.google.com)

它有时候仍然没有得到网站,我认为这是因为硒的开放速度有多慢,但即使在它开放得很好之后它也没有得到这个价值,遗憾的是它只是卡在了一个空的浏览器,在网址窗口中有数据......我知道应该怎么做才能修复它?

2 个答案:

答案 0 :(得分:2)

好的,几个小时之后我决定试一试并改变("')到(''),因为我看到它有效:DI不知道为什么字符串""

有问题

这里是我的代码的编辑行:

chrome.get('https://www.google.com')
  

(我已经尝试使用带有启动webdriver的循环的代理   100次,每当我改变之后,它都会通过)

答案 1 :(得分:0)

您可以使用driver.navigate.to("");

另外,正如我所见,你可能会错过字符串双引号“”,chrome.get(https://www.google.com)