我正在使用Selenium Chrome Webdriver在Python 3中打开网页。 我想有一个可以打开网页的功能。 我最初有:
setModalVisible(visible) {
this.setState({modalVisible: visible});
}
我把它放到函数goTo()
中driver = webdriver.Chrome(executable_path=r'C:\Users\alice\Desktop\chromedriver')
driver.get('https://reports.blm.gov/report/LR2000/23/Pub-MC-Geo-Index')
但是,我无法在该goTo函数之外的该页面上执行任何其他操作。当我尝试时我得到错误:
def goTo():
driver = webdriver.Chrome(executable_path=r'C:\Users\alice\Desktop\chromedriver')
driver.get('https://reports.blm.gov/report/LR2000/23/Pub-MC-Geo-Index')
有谁知道如何使用函数正确打开页面?
答案 0 :(得分:4)
错误说明了一切:
WebDriverException: chrome not reachable
(Session info: chrome=65.0.3325.181)
(Driver info: chromedriver=2.35.528161 (5b82f2d2aae0ca24b877009200ced9065a772e73),platform=Windows NT 10.0.16299 x86_64)
您的主要问题是您使用的二进制文件之间的版本兼容性,如下所示:
支持 Chrome v62-64
支持 Chrome v64-66
因此 ChromeDriver 版本( v2.35 )与 Chrome浏览器版本( v65)之间存在明显的不匹配。 0 )
@Test
。driver.quit()
方法中调用tearDown(){}
以关闭&正常销毁 WebDriver 和 Web客户端实例。