Google chrome closes immediately after being launched with selenium

后端 未结 8 983
说谎
说谎 2021-01-19 09:37

I am on Mac OS X using selenium with python 3.6.3.

This code runs fine, opens google chrome and chrome stays open.:

chrome_options = Options()
chrome         


        
8条回答
  •  小蘑菇
    小蘑菇 (楼主)
    2021-01-19 09:56

    Just simply add:

    while(True):
        pass
    

    To the end of your function. It will be like this:

    def launchBrowser():
       chrome_options = Options()
       chrome_options.binary_location="../Google Chrome"
       chrome_options.add_argument("disable-infobars");
       driver = webdriver.Chrome(chrome_options=chrome_options)
    
       driver.get("http://www.google.com/")
       while(True):
           pass
    launchBrowser()
    

提交回复
热议问题