如何使用Python Selenium Webdriver通过默认的Chrome配置文件打开URL [英] How to open URL through default Chrome profile using Python Selenium Webdriver

查看:525
本文介绍了如何使用Python Selenium Webdriver通过默认的Chrome配置文件打开URL的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我在Mac OS X上使用带python 3.6.3的硒.我正在使用此代码,但是用硒启动浏览器后,谷歌chrome会立即关闭,我启动此代码,谷歌chrome会使用默认配置文件打开新窗口,但chrome不会打开google.com网址.

I am on Mac OS X using selenium with python 3.6.3. Im using this code, but browser Google chrome closes immediately after being launched with selenium I start this code, Google chrome opens new windows with Default profile, but chrome wont open the url google.com.

代码有什么问题?感谢您的帮助!

Whats problem with code? Thanks for the help!

FILE_NAME_PROFILE = '/Users/User/Library/Application Support/Google/Chrome'
options = webdriver.ChromeOptions()
options.add_argument('--user-data-dir='+FILE_NAME_PROFILE)
driver = webdriver.Chrome('assets/chromedriver', chrome_options=options)
driver.get("https://google.com")

推荐答案

我正在使用两个参数,并且在开发中效果很好

I am using two arguments and work well in development

"user-data-dir = C:\ Users \ NameUser \ AppData \ Local \ Google \ Chrome \ User Data"

个人资料目录=默认"

如果要使用另一个配置文件(不是默认配置文件),则必须创建它,而仅需更改第二个参数.所有配置文件都存储在用户数据"文件夹中

If you want use another profile (not default) you have to create it and only you have to change the second argument. All profiles are stored in 'User Data' folder

个人资料目录=个人资料1"

这篇关于如何使用Python Selenium Webdriver通过默认的Chrome配置文件打开URL的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
相关文章
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆