I don't know if selenium does this out of the box, but I managed to find this workaround
element_html = f"<{element.tag_name}>{element.get_attribute('innerHTML')}</{element.tag_name}>"
you may want to replace innerHTML with innerTEXT if you want to get only the text, for example
<li>Hi <span> man </span> </li>
Getting the innerHTML will return all of what inside but the innerTEXT won't, try & see.
now create your Soup object
soup = BeautifulSoup(element_html) print(soup.WHATEVER)
using the above technique, just create a method parseElement(webElement) & use it whenever you want to parse an element.
Btw I only use lxml & when I forgot to type it, the script didn't work
element.textwill just return the text, and lost all the tag.<div> Hi </div>, right?