|
Rank: Newbie Groups: Member
Joined: 7/25/2023 Posts: 5
|
hello, there is a user name and password on the page I opened via eo.webview, I want them to be filled in automatically and logged in. The site I logged in does not belong to me, how can I do this?
i am using c#
|
|
Rank: Administration Groups: Administration
Joined: 5/27/2007 Posts: 24,217
|
Hi,
You would just load the page into the WebView, then use WebView.EvalScript to fill in the user name and password textbox and submit the login form. Basically, you need to do the same thing the end user is doing through JavaScript.
Please keep in mind that this is not always possible. It is very common that a web page would use a CAPTCHA to detect whether it is really a human to log into the page. If that's the case and you try to automate the process using JavaScript, then most likely you will fail the CAPTCHA test. This is the intended result because the very reason the site author place a CAPTCHA on the page is to stop you from automating the page.
Thanks!
|
|
Rank: Newbie Groups: Member
Joined: 7/25/2023 Posts: 5
|
https://sistem.generali.com.tr/I want to do with this site Quote:webView3.EvalScript("document.getElementById('txtUsername').value='user_name';"); i see this error EO.WebBrowser.JSInvokeException: 'EvalScript failed because script engine is not ready or is shutdown before the script can finish. Please use EvalScriptAsync instead of EvalScript to execute JavaScript code in this case.'
|
|
Rank: Administration Groups: Administration
Joined: 5/27/2007 Posts: 24,217
|
Hi, If your application is based on .NET 4.6 and newer, you can try to use EvalScriptAsync instead: https://www.essentialobjects.com/doc/eo.extensions.webviewextensions.evalscriptasync__1_overload_1.htmlYou will need to reference EO.Extensions.dll in order to use this method. Thanks!
|
|
Rank: Newbie Groups: Member
Joined: 7/25/2023 Posts: 5
|
I did what you said still didn't work
|
|
Rank: Newbie Groups: Member
Joined: 7/25/2023 Posts: 5
|
i finished it worked now thanks
i have one more question how can i click the button by id
|
|
Rank: Administration Groups: Administration
Joined: 5/27/2007 Posts: 24,217
|
Hi, You can just do something like this:
Code: C#
await webView3.EvalScriptAsync(@"
document.getElementById('txtUsername').value='user_name';
document.getElementById('txtPassword').value='password';
document.getElementById('ext-gen22').click();
");
The third line clicks the button. Thanks!
|
|
Rank: Newbie Groups: Member
Joined: 7/25/2023 Posts: 5
|
it works thanks :)
|
|
Rank: Administration Groups: Administration
Joined: 5/27/2007 Posts: 24,217
|
Great! Please feel free to let us know if there is anything else.
|
|