Here's a html code;
<div id="div-f2qqs">
<table class="table table-hover table-bordered">
....
</table>
<div class="head-2"></div>
<p></p>
<li></li>
</div>
I want to get all div-f2qqs
's child of outerHTML. How can I do it can anyone help me?
CodePudding user response:
Try
(//div[@id='div-f2qqs']).GetAttribute("outerHTML");
Let me know if this works
CodePudding user response:
outerHTML
The outerHTML attribute of the element DOM interface gets the serialized HTML fragment describing the element including its descendants. It can also be set to replace the element with nodes parsed from the given string.
Ideally to obtain the HTML representation of the contents of an element you should be using the innerHTML property instead.
To obtain the outerHTML
you can use the following Locator Strategies:
Using CssSelector:
Console.WriteLine(driver.FindElements(By.CssSelector("div.div-f2qqs")).GetAttribute("outerHTML"));
Using XPath:
Console.WriteLine(driver.FindElements(By.XPath("//div[@class='div-f2qqs']")).GetAttribute("outerHTML"));