Need to dump entire DOM tree with element id from selenium server

前端 未结 5 1172
误落风尘
误落风尘 2020-12-28 09:36

I have been using python selenium for web automation testing. The key part of automation is to find the right element for a user-visible object in a HTML page. The followin

5条回答
  •  南笙
    南笙 (楼主)
    2020-12-28 10:03

    Try:

    find_elements_by_xpath("//*")
    

    That should match all elements in the document.

    UPDATE (to match question refinements):

    Use javascript and return the DOM as a string:

    execute_script("return document.documentElement.outerHTML")
    

提交回复
热议问题