Welcome Guest Search | Active Topics | Sign In | Register

EO Webbrowser form submit and wait Options
Michael Thompson
Posted: Tuesday, April 19, 2016 7:00:32 AM
Rank: Member
Groups: Member

Joined: 4/17/2016
Posts: 11
I have written a code after searching forums to wait for a button click and completion of its response. You are kindly requested to suggest better approach if there is any. Thanks.

The purpose is to click on a button which submits the form and then wait for its completion to further process the response.

eoWebView.EvalScript(@"document.getElementById('editCartBtn').click();");

EO.WebBrowser.WebView.DoEvents(3000);

for (; ; )
{
if (eoWebView.IsLoading == false)
{
//Do next task
}
else
{
EO.WebBrowser.WebView.DoEvents(3000);
}
}

Note:- We have observed that LoadCompleted is only fired if we set EO WebView Url Property.

eo_support
Posted: Tuesday, April 19, 2016 8:40:29 AM
Rank: Administration
Groups: Administration

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

If you know the form variable names, the best way is to use this method:

http://www.essentialobjects.com/doc/eo.webbrowser.webview.loadrequest.aspx

Or:

http://www.essentialobjects.com/doc/eo.webbrowser.webview.loadrequestandwait.aspx

webView.LoadRequestAndWait is the same as webView.LoadRequest(request).WaitOne(forever). So if you use LoadRequest, you can specify a time out value in the WaitOne call.

Hope this helps.

Thanks!
Michael Thompson
Posted: Tuesday, April 19, 2016 9:01:49 AM
Rank: Member
Groups: Member

Joined: 4/17/2016
Posts: 11
Thanks for your reply.

The suggested method requires to create the Request and in many cases creating a request for each different type of clicks is not a practical job, i.e. gathering request post / get parameters etc.

Please suggest if there is any similar method that submits the request by triggering just a click event on the button and wait for its completion.

eo_support
Posted: Tuesday, April 19, 2016 9:13:55 AM
Rank: Administration
Groups: Administration

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

In that case there is no better alternative than EvalScript. However you should rely on LoadComplete event other than IsLoading. However LoadComplete event SHOULD be fired even in case of a form submit. If it is not firing, then it's a problem. We will look into this and see if we can reproduce it here.

eoWebView.IsLoading is NOT accurate because form post does not occur synchronously. When user clicks a button, the "form post" request is queued by the browser engine on the background and is only submitted at a later time when the browser engine is free, such time delay are usually very short and not noticeable by the end user but it is possible that you can get eoWebView.IsLoading as false immediately after you call EvalScript.

Thanks!
Michael Thompson
Posted: Tuesday, April 19, 2016 9:21:25 AM
Rank: Member
Groups: Member

Joined: 4/17/2016
Posts: 11
This is to confirm that LoadCompleted event is NOT fired if any link "anchor" is clicked through EvalScript or even form submitted.

To reproduce follow the commands below.

--Where editCartBtn is a button element
eoWebView.EvalScript(@"document.getElementById('editCartBtn').click();");

--Where checkout-btn is an anchor element
eoWebView.EvalScript(@"document.getElementById('checkout-btn').click();");

LoadCompleted is only fired if we set Url Property.

eo_support
Posted: Tuesday, April 19, 2016 4:13:15 PM
Rank: Administration
Groups: Administration

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

We have confirmed this to be an issue in the latest build. We will resolve it as soon as possible and reply again when a fix is available.

Thanks!
eo_support
Posted: Friday, April 22, 2016 8:32:23 PM
Rank: Administration
Groups: Administration

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

This is just to let you know that we have posted build .63 that should fix this problem. You can download the new build from our download page.

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.