i coding a small app with some funtion:
can add text to textbox of community(Gplus) and submit my post, but i get fist problem!

G+.png

my code:

            int num = 0;
            HtmlElementCollection elementsByTagName = this.webBrowser1.Document.Body.GetElementsByTagName("div");
            for (num = 0; num < elementsByTagName.Count; num++)
            {
                if (elementsByTagName[num].OuterHtml.Contains("URaP8 Kf Pf b-K b-K-Xb"))
                {

                    elementsByTagName[num].Focus();
                    elementsByTagName[num].InnerText = txtcontent.Text;
                }
                //break;
            }

this code not work for me!
so! anybody can help me?
thanks

this code not work for me!

Your code does not work because
1) you collect all div-elements and
2) elementsByTagName[num].OuterHtml.Contains("URaP8 Kf Pf b-K b-K-Xb") can match with multiple div-elements

Some solutions could be
1) If HTML-element has an id-attribute, use that because it is unique in your web-page:
HtmlElement textBox = this.WebBrowser1.Document.GetElementById("Id for this element");

2) If the element has a name-attribute, try to use it:
if (elementsByTagName[num].Name == "Name of this element")

3) Instead of collection all the div-elements, try to narrow your search. For example, if your textbox is an input-element then get only page's input-tags:
HtmlElementCollection elementsByTagName = this.WebBrowser1.Document.Body.GetElementsByTagName("input");
and narrow results further with element's attributes:
if (elementsByTagName[num].GetAttribute("type") == "text")
Now you would get all the HTML-elements similar to <input type="text"></input>

HTH

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.