0

If I do

match = driver.find_element_by_class_name("match")
print(match.text)

I only get the text in the element.

<class id="match">
    This is a text. This is displayed with .text
    <p align="center"><a href="www.stackoverflow.com"></p>
    The above is not displayed with .text
</class>

What to do when I also want the html in the element, not only the text?

2
  • match variable is the element. Commented Mar 22, 2017 at 19:05
  • Try match.get_attribute('innerHTML') Commented Mar 22, 2017 at 19:09

1 Answer 1

2

If you want to get HTML code inside an element but not including the code of the element you should use this:

element.get_attribute('innerHTML');

If you want to get HTML code inside an element including the code of the element then you should use this:

element.get_attribute('outerHTML')
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.