Rank: Advanced Member Groups: Member
Joined: 10/4/2016 Posts: 104
|
Hi,
Our pages are written in Angular (Single Page Application) and getting the source using webView.getSource() is useless as it does not reflect the actual content of the page.
Surely when debugging it, one can see the full content in the Elements tab of the debugger and eventually by selecting the html element and Edit as HTML, one can obtain the actual content of the page.
However this is not practical because when our users experience an issue, they are not qualified to proceed to those debug steps and it is quasi impossible for us to reproduce their situation.
I would like to take advantage of all the power of your browser to retrieve automatically the actual HTML content as shown is the debugger.
Would you mind to provide me with some tips on how to get this? I doubt there would be an easy way to do it using the exposed API but instead would need to inject some javaScript but... The catch22 is that we need to trigger that from the page, calling an exposed method of the wrapper.
So if that method call back a javascript method into the page, I'm afraid I will run into a deadlock.
If you have any suggestion on how to go by with this, that would be great.
Ideally having one single method that return the actual HTML content would be even better.
Thanks a lot!
|
Rank: Administration Groups: Administration
Joined: 5/27/2007 Posts: 24,221
|
Hi, The recommended way to perform this kind of task is to use EvalScript (or other variant such as QueueScriptCall. Basically whatever you want to do you do it with JavaScript and then use EvalScript to run it. The main benefit of this approach is performance ---- this eliminates all the intermediate roundtrips between the .NET runtime and the browser engine, which is a rather expensive operation. You can find more detailed explanation here: https://www.essentialobjects.com/doc/webbrowser/advanced/jsdom.aspxTo get your page HTML, you can just do something like this:
Code: C#
webView.EvalScript("document.documentElement.innerHTML");
Thanks!
|
Rank: Advanced Member Groups: Member
Joined: 10/4/2016 Posts: 104
|
That's it! Thanks a lot!!! :-)
|