简体   繁体   English

Python Selenium Chrome驱动程序

[英]Python selenium Chrome driver

I am trying to use selenium and chromedriver. 我正在尝试使用硒和chromedriver。 I have downloaded the latest chromedriver and I am trying this. 我已经下载了最新的chromedriver,并且正在尝试这样做。

from selenium import webdriver
driver = webdriver.Chrome('C:\Anaconda2\Scripts\chromedriver.exe')
driver.get("google.com")

I get chrome to come up but I get the following: 我得到chrome,但得到以下信息: 在此处输入图片说明

Why does this not go to google.com? 为什么不转到google.com?

It is fine if that happens. 如果发生这种情况就很好。 Chrome, by default, tells you to disable developer mode on Chrome, to prevent viruses and whatnot. Chrome默认情况下会告诉您在Chrome上禁用开发人员模式,以防止病毒和其他攻击。 It is fine, just keep in mind that having developer mode on will make your computer vulnerable to viruses. 很好,请记住,启用开发人员模式会使您的计算机容易受到病毒的攻击。 If your code is not working, then that is a different question. 如果您的代码无法正常工作,那就是另一个问题。

Here is the Answer to your Question: 这是您的问题的答案:

When you work with Selenium 3.4.0, chromedriver v2.30 and Google Chrome 59.0 through Python 3.6.1 , you can use the argument chrome_options while initiating the WebDriver instance to disable the extensions and disable the infobar as follows: 当您通过Python 3.6.1使用Selenium 3.4.0, chromedriver v2.30和Google Chrome 59.0时,可以在启动WebDriver实例时使用参数chrome_options来禁用扩展并禁用信息栏,如下所示:

from selenium import webdriver
from selenium.webdriver.chrome.options import Options

options = Options()
options.add_argument("start-maximized")
options.add_argument("disable-infobars")
options.add_argument("--disable-extensions")
driver = webdriver.Chrome(chrome_options=options, executable_path="C:\\Utility\\BrowserDrivers\\chromedriver.exe")
driver.get('http://google.com/')

Let me know if this Answers your Question. 让我知道这是否回答了您的问题。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM