2017-12-20 2 views
0

크롬 브라우저에 여러 개의 사용자 정의 프로필이 있습니다. 예를 들어, "test 2"프로파일을 사용하여 셀레늄에서 사용하고 싶습니다.미리 정의 된 크롬 프로파일을 셀레늄에서 파이썬으로 사용하는 방법은 무엇입니까?

https://i.stack.imgur.com/iYcG8.png

내가 인터넷에서 볼 수있는 코드입니다 (아래 그림 참조).

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

options = webdriver.ChromeOptions() 
options.add_argument(r'user-data-dir=C:\Users\mycomputer\AppData\Local\Google\Chrome\User Data') 
browser = webdriver.Chrome(executable_path=r"C:\Users\mycomputer\AppData\Local\Programs\Python\Python36-32\chromedriver.exe", chrome_options=options) 

"테스트 2"프로필은 어떻게 사용할 수 있습니까? 고맙습니다. - 프로필의 디렉토리이고 이름은 프로파일 이름처럼되지 않습니다

options.add_argument('--profile-directory=Profile 1') 

Profile 1 :

답변

2

당신은 하나 개 더 인수를 추가해야합니다. user-data-dir에서 모든 프로필 디렉토리를 탐색 할 수 있습니다. "test 2"프로필에 대한 dir이 무엇인지 알아내는 방법 - 여기에서 찾을 수 있습니다 https://superuser.com/a/723145

+0

awesome. 완벽하게 작동합니다. 고맙습니다! –

관련 문제