Following the guide Scraping Websites with Python, Selenium, and Tor I don’t know how could I wait only until the tor browser is connected instead of waiting a fixed amount of time. Something like what there is in the comment below, which isn’t working right now. The torStatus is just an example with doesn’t really exist. I’m looking for an actual way to tell when it is connected.

def connect_tor() -> None:
    driver.find_element(By.XPATH, '//*[@id="connectButton"]').click()
    #while driver.find_element(By.XPATH, '//*[@id="torStatus"]').get_attribute("value") != "connected":
        #time.sleep(1)
    time.sleep(20)