|
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.
|
|
Rank: Administration Groups: Administration
Joined: 5/27/2007 Posts: 24,229
|
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.aspxOr: http://www.essentialobjects.com/doc/eo.webbrowser.webview.loadrequestandwait.aspxwebView.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!
|
|
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.
|
|
Rank: Administration Groups: Administration
Joined: 5/27/2007 Posts: 24,229
|
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!
|
|
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.
|
|
Rank: Administration Groups: Administration
Joined: 5/27/2007 Posts: 24,229
|
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!
|
|
Rank: Administration Groups: Administration
Joined: 5/27/2007 Posts: 24,229
|
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!
|
|