1
votes

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

1 Answers

1
votes

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