Click here to Skip to main content
15,867,986 members
Please Sign up or sign in to vote.
1.00/5 (1 vote)
I was able to do it similarly in internet explorer, but when I do it based on firefox, I get an error
C#
private void button1_Click(object sender, EventArgs e)
{
    geckoWebBrowser1.Navigate(textBox1.Text);
}

private void button2_Click(object sender, EventArgs e)
{
    var links = geckoWebBrowser1.Document.GetElementsByTagName("input");
    foreach (GeckoElement link in links)
    {
        if (link.GetAttribute("className") == "search__input")
            link.InnerText = textBox2.Text;
    }
}

Error : link.InnerText = textBox2.Text;

What I have tried:

I used to use foreach (HtmlElement link in links)
now foreach (GeckoElement link in links)
Posted
Updated 26-Jan-23 11:39am
v2
Comments
Afzaal Ahmad Zeeshan 25-Jan-23 20:59pm    
And what is the complete error?

I saw this article this morning that should answer your questions: Web Scraping with C# | ScrapingBee[^]
 
Share this answer
 
An <input> element doesn't have an InnerText property. Try setting its Value property instead.

NB: You'll probably need to change your loop variable to GeckoInputElement instead.
C#
var links = geckoWebBrowser1.Document.GetElementsByTagName("input");
foreach (GeckoInputElement link in links)
{
    if (link.GetAttribute("className") == "search__input")
        link.Value = textBox2.Text;
}
 
Share this answer
 
thank you very much i solved it in a different way
I solved it the easier way using cefsharp

code :
browser.ExecuteScriptAsync("document.getElementById('join_neu_email_field').value ='aa';");
            browser.ExecuteScriptAsync("document.getElementById('join_neu_password_field').value ='aa';");


When you say thank you for your help I will try it, I will use whichever is more comfortable
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900