How Can I Interact With The Page Before Loading?
I have encountered a problem using selenium with python. I'm trying to interact with a page like this: driver_window_manager.get(url) iframe = driver_window_manager.find_elements_b
Solution 1:
The blocking behaviour you describe is because of the default page load strategy in Selenium. You can alter this via the desiredCapabilities or options class for your chosen browser.
InternetExplorerOptionsieOptions= ieOptions();
ieOptions.setPageLoadStrategy(PageLoadStrategy.NONE);
driver = newInternetExplorerDriver(ieOptions);
Solution 2:
driver.get
waits for the page to be loaded and then only proceeds further, if you don't want to wait, then you need to use javascript to load the URL with execute_script
. It returns immediately so that you can perform any actions you want -
driver.execute_script("window.open(your_url);")
Now, if you want to, for example accept a popup, you can do -
WebDriverWait(driver, 10).until(EC.alert_is_present())
alert = driver.switch_to.alert
alert.accept()
Note, you need to add the following imports:
from selenium.webdriver.support.uiimportWebDriverWaitfrom selenium.webdriver.supportimport expected_conditions asEC
Post a Comment for "How Can I Interact With The Page Before Loading?"