1

Is it possible to reparse the page using selenium? I click a button using the function then the HTML changes because of javascript and I want to reparse the page, not refresh it.

The methods of get/refresh cause the page to reload which isn't what I'm looking for.

1 Answer 1

2

It is not exactly "reparsing" actually. From what I understand this is about detecting the changes made on the page. For that, you should use WebDriverWait and a set of built-in expected conditions (or you can write a custom one) to wait for that change to be made on the page.

Let's say, for instance, an element is added to the page when you click the button. Here is how to wait until this element is visible:

from selenium.webdriver.common.by import By from selenium.webdriver.support.ui import WebDriverWait from selenium.webdriver.support import expected_conditions as EC # ... button.click() wait = WebDriverWait(driver, 10) wait.until(EC.visibility_of_element_located((By.CSS_SELECTOR, "#id-of-the-added-element"))) # now the page is "re-parsed" print(driver.page_source) 

It would wait up to 10 seconds checking the state of the expected condition every 500 milliseconds (by default).

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

Comments

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.