Follow

Keep Up to Date with the Most Important News

By pressing the Subscribe button, you confirm that you have read and are agreeing to our Privacy Policy and Terms of Use
Contact

Can i turn off headless chrome while code is running then turn it on back again?

Hello so i have been trying alot but i think it’s impossible i need to run chrome driver using python selenium with headless on but at some point i want to turn off headless mode (in the middle of debugging for example) so i can solve the captcha or do something .. is it possible ?


from selenium import webdriver
from selenium.webdriver.support.ui import WebDriverWait
import chromedriver_autoinstaller


link = "https://www.google.com/recaptcha/api2/demo"
WINDOW_SIZE = "1920,1080"


try :  
        chromedriver_autoinstaller.install()
        chrome_options = webdriver.ChromeOptions()
        chrome_options.add_argument("--incognito")
        chrome_options.add_argument("--log-level=3")
        chrome_options.add_argument("--headless")
        chrome_options.add_argument("--window-size=%s" % WINDOW_SIZE)
        driver = webdriver.Chrome(chrome_options=chrome_options)
        wait = WebDriverWait(driver, 10)
        driver.maximize_window()


        driver.get(link)
        #i want to turn off headless here so i can solve the captcha for example 
        print("Cpathca Solved")
        #Then turn it back on again here
except :
    pass        

>Solution :

MEDevel.com: Open-source for Healthcare and Education

Collecting and validating open-source software for healthcare, education, enterprise, development, medical imaging, medical records, and digital pathology.

Visit Medevel

No, you can’t.
webdriver object is created with specified (or default) parameters that can’t be changed during the session.

Add a comment

Leave a Reply

Keep Up to Date with the Most Important News

By pressing the Subscribe button, you confirm that you have read and are agreeing to our Privacy Policy and Terms of Use

Discover more from Dev solutions

Subscribe now to keep reading and get access to the full archive.

Continue reading