|
Rank: Member Groups: Member
Joined: 3/21/2020 Posts: 12
|
Code: Visual Basic.NET
dim js as string = "document.querySelector(""#fm-login-id"").value=""username"";document.querySelector(""#fm-login-password"").value=""userpass"";document.querySelector(""button[type=submit]"").click();"
WebView1.LoadUrl("https://pub.alimama.com/promo/search/index.htm?spm=a219t.11816994.1998910419.dd412374a2.6d3575a5TCfvnA")
WebView1.EvalScript(js)
I want use the JS to Login the page if I use the JS in chrome's console >> yes,it is effective but when I use the same JS in webview >> can't ,webview show the error msg " line 1, col 44 - 45: Uncaught TypeError: Cannot set property 'value' of null" What causes this?? THX :)
|
|
Rank: Administration Groups: Administration
Joined: 5/27/2007 Posts: 24,217
|
Hi,
You are calling EvalScript too soon. LoadUrl starts loading the page and returns immediately. So by the time you call EvalScript the page has not finished loading yet. You can try to change LoadUrl to LoadUrlAndWait and see if it works for you.
Thanks!
|
|
Rank: Member Groups: Member
Joined: 3/21/2020 Posts: 12
|
eo_support wrote:Hi,
You are calling EvalScript too soon. LoadUrl starts loading the page and returns immediately. So by the time you call EvalScript the page has not finished loading yet. You can try to change LoadUrl to LoadUrlAndWait and see if it works for you.
Thanks! Not for this reason. In fact, JS is controlled by a separate button in my code
|
|
Rank: Administration Groups: Administration
Joined: 5/27/2007 Posts: 24,217
|
Hi, You can use the built-in debugger to debug the page to find out why your JS code if failing: https://www.essentialobjects.com/doc/webbrowser/advanced/debug.aspxThanks!
|
|
Rank: Member Groups: Member
Joined: 3/21/2020 Posts: 12
|
|
|
Rank: Administration Groups: Administration
Joined: 5/27/2007 Posts: 24,217
|
Hi,
You can run TabbedBrowser sample application and then test your code using the sample application's Console window (click the menu button and then select "Console"). There should be no difference between this console window and EvalScript because internally the console window calls EvalScript (see source code in txtScript_PreviewKeyDown in ConsolePanel.xaml.cs). If this console window works and your application does not, then there is something different in your application that you will need to find out.
If this console window does not work either, try the console window in the built-in debug UI. If that works, then you can isolate the problem into a test project and send the test project to us and we will investigate further.
Additionally, please PM us your order number as we will need to verify that as well.
Thanks!
|
|