Python Selenium accessing HTML source

The Solution to Python Selenium accessing HTML source is


You need to access the page_source property:

from selenium import webdriver

browser = webdriver.Firefox()
browser.get("http://example.com")

html_source = browser.page_source
if "whatever" in html_source:
    # do something
else:
    # do something else

~ Answered on 2011-10-23 15:08:06


Most Viewed Questions: