Awesomium WebControl Clicking/Writing

502 views Asked by At

I am trying to let click/write on the Awesomium WebControl, but it doesn't work. This is the code that I use:

WebControl1.Source = New Uri("website") 'i dont put the website
xpath=link.xpath
Dim nlink As JSObject = WebControl1.ExecuteJavascriptWithResult([String].Format("document.evaluate(""{0}"", document, null, XPathResult.FIRST_ORDERED_NODE_TYPE, null ).singleNodeValue", xpath))

nlink.InvokeAsync("click")
end if
next
1

There are 1 answers

12
voytek On

If you want to just trigger 'click' on your website content, that should work (using jQuery):

WebControl1.ExecuteJavascript(@"$(document.body).trigger('click');");

or (I've found it here, not tested):

        dynamic document = (JSObject)webView.ExecuteJavascriptWithResult("document");

        if (document == null)
            return;

        using (document)
        {
            dynamic signin = document.getElementById("signin");

            if (signin == null)
                return;

            using (signin)
                signin.click();
        }

Remember to wait till DocumentReady is Loaded state:

    private void BaseWebControl_DocumentReady(object sender, DocumentReadyEventArgs e)
    {
        if (e.ReadyState != DocumentReadyState.Loaded) return;

        // Now! 
    }

EDIT:

<a id="foo" href="http://...." target="_blank">Test link</a>

in jQuery:

jQuery('#foo')[0].click();