3

Using the selenium module, how do I dump the current page's HTML (for debugging purposes)? It doesn't say how to here: http://selenium-python.readthedocs.io/api.html

James Ko
  • 32,215
  • 30
  • 128
  • 239
  • this helps you? https://stackoverflow.com/questions/25356440/need-to-dump-entire-dom-tree-with-element-id-from-selenium-server – Tales Pádua Apr 02 '18 at 20:36

2 Answers2

3

For debugging purpose to dump the current page's HTML you can invoke the page_source method as :

driver.page_source
undetected Selenium
  • 183,867
  • 41
  • 278
  • 352
2

You can dump the current page's HTML content using the WebDriver property page_source.

Sample snippet:

from selenium import webdriver
driver = webdriver.Firefox()
driver.get('https://yourfavoriteurl')
if 'interested_string' in driver.page_source:
    print('String matched!')
Swadhikar
  • 2,152
  • 1
  • 19
  • 32