Welcome Guest Search | Active Topics | Sign In | Register

Webview EvalScript error when using without UI Options
Daniel Salgado
Posted: Friday, March 30, 2018 11:20:45 AM
Rank: Newbie
Groups: Member

Joined: 3/30/2018
Posts: 1
I wanna retrieve a value from the a page after this page loads using a javascript call from the server side in my API. I'm getting an error when I do this using a ThreadRunner to CreateWebView without UI, this is my code.
Quote:

ThreadRunner threadRunner = new ThreadRunner();
//Create a WebView through the ThreadRunner
WebView webView = threadRunner.CreateWebView();
threadRunner.Send(() =>
{
webView.LoadUrlAndWait("http://localhost/bel.public.api.imaging/previewgenerator/generator");
var base64 = (string)webView.EvalScript("designInstance.productData.modelData.renderer.domElement.toDataURL();", true);
});


I'm getting an error saying "designInstance.productData.modelData.renderer" is undefined but when I do the same using WinForms and the control, like this, works fine:
Quote:

public partial class Form1 : Form
{
public Form1()
{
InitializeComponent();
webView1.Url = @"http://localhost/bel.public.api.imaging/previewgenerator/generator";
webView1.Reload();

}
private void webView1_LoadCompleted(object sender, EO.WebBrowser.LoadCompletedEventArgs e)
{

var base64 = (string)webView1.EvalScript("designInstance.productData.modelData.renderer.domElement.toDataURL();");
}
}


How I can put it work on the APi???
eo_support
Posted: Saturday, March 31, 2018 1:11:58 PM
Rank: Administration
Groups: Administration

Joined: 5/27/2007
Posts: 24,221
Hi,

This has to do with your page and there is no way we can tell you why a variable you are looking for exists in one case and does not exist in another case. What you can do is to use the built-in remote debugger feature to find out why the variable is not initialized:

https://www.essentialobjects.com/doc/webbrowser/advanced/remote_debug.aspx

Thanks!



You cannot post new topics in this forum.
You cannot reply to topics in this forum.
You cannot delete your posts in this forum.
You cannot edit your posts in this forum.
You cannot create polls in this forum.
You cannot vote in polls in this forum.