Rank: Member Groups: Member
Joined: 10/17/2019 Posts: 14
|
Sometimes we will encounter a web page that is not ready for a long long time, But in fact, it's elements can already be used.
such as: WebView1.LoadUrlAndWait("https://www.cbs.com/cbs-all-access/signin/")
How to fill in and submit as soon as the email and password elements are available???
|
Rank: Administration Groups: Administration
Joined: 5/27/2007 Posts: 24,218
|
Hi,
There is no build in support on this. LoadUrlAndWait will wait until the entire body elements finishes loading. So for example, if your element is in the first half of the document and the first half has been loaded but the second half has not been loaded yet, LoadUrlAndWait will not return.
There are a number of ways you can do to check whether an element is ready --- all of which would involve JavaScript. You can either use call WebView.EvalScript periodically from the .NET side to perform the check, or you can use WebView.JSInitCode to inject some code into the WebView and setup timer to perform checks over there. The difference between these two is WebView.JSInitCode is run before any other code in your page runs.
Lastly, it is NOT recommended you to fill the form this way because the page might rely on contents that are not loaded yet. For example, if the server renders a hidden input field that contains some kind of verification/signature data and you submit the page before that field is loaded, then the server will fail such request because it doesn't see the hidden field that it put there earlier.
Thanks!
|