I have a python script written to load ' to redirect to a captive portal, then some implicit wait functions to wait for the login boxes and login button elements.

I know the code works because i've tried it when I'm already logged in and connected to the internet, and it successfully completes the login portal (when I manually redirect to it).

However when I first join the network and try to run the script, it hangs on loading and starting the chrome webdriver (I know this based on the traceback when I press ctrl+c). I think it may have something to do with waiting for internet or for the page to load, however I am not interested in either as I just need it to launch and wait for a few html elements.

Does anyone know what could be happening, or have any flags I could pass to the webdriver to make it ignore the status of my internet connection?

Code I'm using:

import sys import time from selenium import webdriver from selenium.webdriver.support.ui import WebDriverWait from selenium.webdriver.support import expected_conditions as EC from selenium.webdriver.common.by import By from selenium.webdriver.chrome.options import Options from selenium.common.exceptions import NoSuchElementException def implicit_wait_byid(driver, element): try: item = WebDriverWait(driver, 10).until( EC.presence_of_element_located((By.ID, element)) ) return item except NoSuchElementException: sys.exit("Error loading page content. Please try again.") def implicit_wait_byname(driver, element): try: item = WebDriverWait(driver, 10).until( EC.presence_of_element_located((By.NAME, element)) ) return item except NoSuchElementException: sys.exit("Error loading page content. Please try again.") def implicit_wait_byxpath(driver, element): try: item = WebDriverWait(driver, 10).until( EC.presence_of_element_located((By.XPATH, element)) ) return item except NoSuchElementException: sys.exit("Error loading page content. Please try again.") chrome_options = Options() # chrome_options.add_argument("--headless") # chrome_options.binary_location = "/usr/bin/chromedriver" # chrome_options.add_argument("--disable-dev-shm-usage") # chrome_options.add_argument("--no-sandbox") chrome_options.page_load_strategy = 'none' driver = webdriver.Chrome(options=chrome_options) # code stops here without internet, with internet it runs fine. driver.get("") implicit_wait_byname(driver, "name").send_keys("d") implicit_wait_byname(driver, "email").send_keys("[email protected]") implicit_wait_byname(driver, "auth_method").click() exit(0) 

Chrome version and webdriver version are 116. Python is version 3.11.3.

I've tried different flags, and changing the page loading strategy.

Related questions 2 Why Selenium webdriver with Python can't reach to a website 3 TimeoutException: Message: 0 selenium Webdriver wait until expected conditon not working properly on Amazon EC2 instance Related questions 2 Why Selenium webdriver with Python can't reach to a website 3 TimeoutException: Message: 0 selenium Webdriver wait until expected conditon not working properly on Amazon EC2 instance 0 How to make selenium 3.4.0 wait for page load? 0 How to modify the default wait for 30 seconds for elements that cannot be found? 4 How to ask Selenium2 to finish loading a page on .Click before doing any assertions? 0 C# Selenium WebDriverWait.IgnoreExceptionTypes does not work Load 4 more related questions Show fewer related questions

Reset to default

Know someone who can answer? Share a link to this question via email, Twitter, or Facebook.

Your Answer

Sign up or log in

Sign up using Google Sign up using Facebook Sign up using Email and Password

Post as a guest

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge that you have read and understand our privacy policy and code of conduct.