Splinter or Selenium: Can we get current html page after clicking a button?

有些话、适合烂在心里 提交于 2019-12-04 05:07:17

With Selenium, assuming that driver is your initialized WebDriver object, this will give you the HTML that corresponds to the state of the DOM at the time you make the call:

driver.execute_script("return document.documentElement.outerHTML;")

The return value is a string so you could do:

print(driver.execute_script("return document.documentElement.outerHTML;"))

When I use Selenium for tasks like this, I know browser.page_source does get updated.

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!