Get HTML Source of WebElement in Selenium WebDriver using Python
Wed Jun 17, 2020 2:22 pm
I'm using the Python bindings to run Selenium WebDriver:
Any thoughts on the best way to access the HTML of an element (and its children)?
- Code:
from selenium import webdriver
wd = webdriver.Firefox()
- Code:
elem = wd.find_element_by_css_selector('#my-id')
- Code:
wd.page_source
- Code:
elem.source # <-- returns the HTML as a string
Any thoughts on the best way to access the HTML of an element (and its children)?
Permissions in this forum:
You cannot reply to topics in this forum