1

I am trying to get the innerHTML of an element using:

de_nc = driver.find_element_by_css_selector('element').get_attribute("innerHTML")

But i get the following:

<a href=""https://****/""><u>Text</u></a>

Instead of the following:

<a href="https://****/"><u><font style="vertical-align: inherit;"><font style="vertical-align: inherit;">Text</font></font></u></a>
2
  • is the font element generated dynamically? Commented Jan 2, 2020 at 8:11
  • We are going to need to input daya to assist. Commented Jan 2, 2020 at 8:11

2 Answers 2

1

To extract the innerHTML of an element you have to induce WebDriverWait for the visibility_of_element_located() and you can use either of the following Locator Strategy:

print(WebDriverWait(driver, 20).until(EC.visibility_of_element_located((By.CSS_SELECTOR, "element_css"))).get_attribute("innerHTML"))
Sign up to request clarification or add additional context in comments.

1 Comment

This does not solve. I already tried with WebDriverWait too.
0

You can use outerHTML attribute so it will return the HTML of the element itself with all the children elements. try this:

de_nc = driver.find_element_by_css_selector('element').get_attribute("outerHTML")

Comments

Your Answer

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

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.