python - Need to dump entire DOM tree with element id from selenium server -
i have been using python selenium web automation testing. key part of automation find right element user-visible object in html page. following api work of time, not time.
find_element_by_xxx, xxx can id, name, xpath, tag_name etc.
when html page complicated, search dom tree. wonder if it's possible ask selenium server serialize entire dom (with element id can used perform action on through webdriver server). client side (python script) can own search algorithm find right element.
note python selenium can entire html page
drv.page_source
however, parsing doesn't give internal element id selenium server's point of view, hence not useful.
edit1: paraphrase make more clear (thanks @alecxe): what's needed here serialized representation of dom elements (with dom structure preserved) in selenium server, serialized representation can sent client side (a python selenium test app) can own search.
try:
find_elements_by_xpath("//*")
that should match elements in document.
update (to match question refinements):
use javascript , return dom string:
execute_script("document.documentelement.outerhtml")
Comments
Post a Comment