How to switch from chrome chrome to chrome chrome when condition is met?
Is it possible to switch from headless chrome to chrome when a certain condition is met / or when something is called?
Here is my code:
import os
from selenium import webdriver
from selenium.webdriver.common.keys import Keys
from selenium.webdriver.chrome.options import Options
chrome_options = Options()
chrome_options.add_argument("--headless")
chrome_options.binary_location = """/Applications/Google Chrome
Canary.app/Contents/MacOS/Google Chrome Canary"""
driver = webdriver.Chrome(executable_path=os.path.abspath("chromedriver"))
chrome_options=chrome_options
driver.get("http://www.google.com")
I tried to remove the options, but that doesn't seem to work ... I'm trying to go from a headless form to a form when a certain element appears ...
if "google" in driver.page_source:
"SWITCH TO HEADED BROWSER HERE AND DISPLAY THE SITE"
I know I can always just close the instance and open a new instance, but I was wondering if there is a way to do it this way, so the browser is essentially hidden until the condition is met.
+3
source to share
No one has answered this question yet
Check out similar questions: