Welcome Guest Search | Active Topics | Sign In | Register

Something like GetByElement in EO Web Browser WinForms Options
Girard
Posted: Wednesday, September 30, 2020 12:29:25 PM
Rank: Newbie
Groups: Member

Joined: 9/30/2020
Posts: 3
I state that I am a beginner.

I am creating a C# WinForms application where there is a button that auto enters the user's password and username from a textbox;
I saw that onr support page there is the metod but I don't understand how to use it.

Normally in c # the code is:

private void button1_Click_4(object sender, EventArgs e)
{
webBrowser1.Document.GetElementById("username").SetAttribute("value", webBrowser1e_Username_TextBox.Text);
webBrowser.Document.GetElementById("password").SetAttribute("value", webBrowser1_Password_TextBox.Text);

How can I use this code with EO web browser for WinForm ???



Sorry for my little English
Code: C#
eo_support
Posted: Wednesday, September 30, 2020 1:46:32 PM
Rank: Administration
Groups: Administration

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

You will need to use JavaScript code to do that. In your case, you can do something like this:

Code: C#
webView.EvalScript("document.getElementById('username') = '" + userName + "';");


For the reason behind this, please see here:

https://www.essentialobjects.com/doc/webbrowser/advanced/jsdom.aspx

Thanks!
Girard
Posted: Thursday, October 1, 2020 12:23:36 PM
Rank: Newbie
Groups: Member

Joined: 9/30/2020
Posts: 3
'm sorry but it doesn't work.

I copied the code, adapting it to the names of my web wiew and my username but it doesn't work in any way.
Maybe I'm wrong something ???
eo_support
Posted: Thursday, October 1, 2020 1:25:56 PM
Rank: Administration
Groups: Administration

Joined: 5/27/2007
Posts: 24,067
I am sorry. The corresponding JavaScript code should be:

Code: JavaScript
document.getElementById("userName").value = newValue;


The previous post missed the ".value" part.

This is just to show you the concept ---- in the future you will need to troubleshoot JavaScript code yourself.
Girard
Posted: Thursday, October 1, 2020 4:36:23 PM
Rank: Newbie
Groups: Member

Joined: 9/30/2020
Posts: 3
If I solve my problem I come back here to thank you


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.