I\'m using Selenium with C#. I have code which returns me a script tag as an IWebElement
. How do I get the content from it?
The best you can do is use GetAttribute
and access it's innerHTML
.
element.GetAttribute("innerHTML");
You can try this:
WebElement element = driver.findElement(By.tagName("script"));
String htmlCode = (String) ((JavascriptExecutor) driver).executeScript("return arguments[0].innerHTML;", element);
P.S. is in Java but you can do same in C# with some small edit.