1

Scenario:

I have been able to click the button using c# and a webbrowser, but now I want to add text inside a text field after the pop up has opened.

Imagine the Events Tab on Facebook.

When you make an event it pops up a little box where you can enter text (AJAX).

I am trying to get the text from my text boxes into those text fields, after it has popped up and fully loaded.

I have tried using the async and await keywords with no luck, I have tried scanning the page but the pop up happens using AJAX so I can't rescan the page(I don't think) to grab the right div id to enter text in?

Any idea's?

Thanks

Here is my code so far:

private void web_postFB(object sender,
            WebBrowserDocumentCompletedEventArgs e)
        {
                if (btnClicked == false)
                {
                    var links = web.Document.GetElementsByTagName("a");
                    foreach (HtmlElement link in links)
                    {
                        if (link.GetAttribute("className") == "mrs mlm _42ft _4jy0 _4jy3 _517h")
                        {
                            link.InvokeMember("click");
                        }
                        if (web.Document.GetElementById("u_f4_3") != null)
                        {
Here is where I want it to wait for the pop up to be fully opened. Then do the method below to insert the text into the text fields.

                            inputText();
                        }
                    }
                }
        }
noseratio
  • 59,932
  • 34
  • 208
  • 486
Matt Williams
  • 79
  • 1
  • 8

1 Answers1

0

This is most likely an adorned HTML popup, not a real window. You can try to process it with asynchronous polling of WebBrowser.Document.Body.InnerHtml for changes, using webBrowser.IsBusy, Task.Delay and async/await. A complete example can be found here.

Community
  • 1
  • 1
noseratio
  • 59,932
  • 34
  • 208
  • 486