[英]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.