How to get HTML code of a WebElement in Selenium

后端 未结 6 1069
离开以前
离开以前 2020-12-18 17:44

I am new at testing so my apologies in advance if my question sounds a bit primary.

I am using Selenium and Java to write a test.

I know that webElem

6条回答
  •  青春惊慌失措
    2020-12-18 18:38

    If you want the HTML of the element itself, you can use

    webElement.getAttribute("outerHTML");
    

    It will return the HTML of the element itself plus all the children elements. I'm not sure if that's exactly what you want. I don't think there is a way to just get the HTML of the selected element only.

提交回复
热议问题