Awesomium WebControl点击/写作

时间:2015-06-04 19:52:02

标签: awesomium

我想在Awesomium WebControl上点击/写一下,但它不起作用。 这是我使用的代码:

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 个答案:

答案 0 :(得分:1)

如果您只想触发网站内容的“点击”,那应该有效(使用jQuery):

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

或(我发现它here,未经测试):

        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();
        }

请记住等到DocumentReady处于Loaded状态:

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

        // Now! 
    }

编辑:

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

在jQuery中:

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