0

I use python and selenium to operate chrome,if I use default user-data-dir it works,but use new user-data-dir it blocks before opening first url.

  #default_path = r'C:\Users\%s\AppData\Local\Google\Chrome\User Data' % username 
    default_path = r'D:\User Data'
    option.add_argument('--user-data-dir=%s' % default_path)
    driver = webdriver.Chrome(chrome_options=option,executable_path=r'C:\Users\Administrator\Desktop\chromedriver.exe')

After test I found the chrome blocks because it can't load google.com in china! if i don't use 'user-data-dir' argument,it use 'data:,' as default address. So I want to know how can I open chrome without open google.com as default address(such as use 'data:,' )

mengzz
  • 71
  • 1
  • 5

1 Answers1

0

Here you can find list of chromium command line switches. I believe it's also valid for chrome. There is --homepage switch, that allows setting homepage to be opened in any new opened tab. So I believe you can solve your problem by setting:

option.add_argument('--homepage=%s' % some_page_other_than_google)
running.t
  • 5,329
  • 3
  • 32
  • 50
  • it doesn't work,the chrome doesn't open homepage ever ,but I found a solution for this problem: option.add_argument(' google-base-url=MY_URL') – mengzz Jul 12 '18 at 08:04