1

I have a automation with Selenium, and i want to run some commands after open the link but no waiting for load the page, i want to run this codes even the page is not completely load, or while the page is loading

from selenium import webdriver
from selenium.webdriver.common.by import By
from selenium.webdriver.support.wait import WebDriverWait
from selenium.webdriver.support import expected_conditions as EC

driver = webdriver.Chrome(executable_path=r"C:\Users\Gabri\anaconda3\chromedriver.exe")
wait: WebDriverWait = WebDriverWait(driver, 10)
driver.get('https://stackoverflow.com/')

# I want to run some commands in this lines, without wait the page load
...


# I did this wait just for print when the page completely load
wait.until(EC.presence_of_element_located((By.CSS_SELECTOR,
                                           'body > header > div > div.-main.flex--item > a.-logo.js-gps-track > span')))

print('The page is completely load')
driver.quit()

The commands that i want to run in ... no have relation with the page, that is why i need run without wait the page load

1 Answer 1

0

The simplest way to run these methods without waiting for the page loaded is to run them before involving the driver.get('https://stackoverflow.com/') method

Sign up to request clarification or add additional context in comments.

2 Comments

I know, but is no possible add a option in driver = webdriver.Chrome(path, option) or something like this?
I'm not familiar with such options.

Your Answer

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