简体   繁体   中英

C# Selenium get Html document after it has been modified

Basically I have the following HTML source:

<b class="number"> Click to see </b>

And when you click on this, this is its JS code:

function fun(){
   number.html("12345");
}

Now, thanks to driver.ExecuteScript("arguments[0].click();", element); I am able to show the number, but when I execute driver.PageSource(); , in the Html document I keep seeing "Click to see" rather than "12345". How to overcome this? Thank you in advance

Use JavaScript to get the current outerHTML:

var js = (IJavaScriptExecutor)driver;
var newHtml = js.ExecuteScript("return document.documentElement.outerHTML;");

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM