简体   繁体   English

如何使用Python Selenium Webdriver通过默认的Chrome配置文件打开URL

[英]How to open URL through default Chrome profile using Python Selenium Webdriver

I am on Mac OS X using selenium with python 3.6.3. 我在Mac OS X上将硒与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. 我正在使用此代码,但是用硒启动浏览器后Google chrome立即关闭,我启动了此代码,Google chrome使用默认配置文件打开了新窗口,但chrome不会打开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" “ user-data-dir = C:\\ Users \\ NameUser \\ AppData \\ Local \\ Google \\ Chrome \\ User Data”

"profile-directory=Default" “配置文件目录=默认”

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 所有配置文件都存储在“用户数据”文件夹中

"profile-directory=Profile 1" “配置文件目录=配置文件1”

暂无
暂无

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

相关问题 如何使用 Python Selenium Webdriver 在 Chrome 中加载默认配置文件? - How to load default profile in Chrome using Python Selenium Webdriver? 使用 Python 通过 Selenium WebDriver 打开 chrome 扩展 - Open a chrome extension through Selenium WebDriver using Python 使用mac上的python和selenium打开使用默认用户配置文件的chrome - Open chrome with default user profile using python and selenium on mac 如何使用 Python Selenium Webdriver 在 Chrome 中加载自定义配置文件? - How to load custom profile in Chrome using Python Selenium Webdriver? 在python中使用默认的firefox配置文件和selenium webdriver - Using the default firefox profile with selenium webdriver in python 如何在 Selenium Webdriver Python 3 中使用 Chrome 配置文件 - How to use Chrome Profile in Selenium Webdriver Python 3 如何使用Selenium WebDriver和python打开功能齐全的Chrome浏览器? - How to open a fully functioning chrome browser using selenium WebDriver with python? 如何在python中将现有的Google Chrome配置文件与Selenium Chrome Webdriver一起使用? - How to use an existing google chrome profile with selenium chrome webdriver in python? Selenium python - 如何加载默认 Chrome 配置文件 - Selenium python - How to load Default Chrome Profile 在任何PC上使用默认的Firefox配置文件进行Selenium(python)Webdriver授权 - Selenium(python) webdriver authorization using default firefox profile on any PC
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM