XAML C#Store App中没有webBrowser1.Document.GetElementById和SetAttribute

时间:2013-10-31 13:10:11

标签: c# xaml web windows-store-apps bots

我想在xaml c#windows 8商店应用中控制网络浏览器 但是我看不到方法 我在c#中用于表单应用程序的那个在下面给出

private void webBrowser1_DocumentCompleted(object sender, WebBrowserDocumentCompletedEventArgs e)
        {
            if (webBrowser1.DocumentText.Contains("xxxx"))
            {
                webBrowser1.Document.GetElementById("login").SetAttribute("value", "admin");
                webBrowser1.Document.GetElementById("pass").SetAttribute("value", "password1");
                webBrowser1.Document.GetElementById("submit").InvokeMember("click");
            }
}

如何在Windows 8 xaml c#store应用程序中使用相同的功能?

1 个答案:

答案 0 :(得分:0)

尝试:

webView1.InvokeScript(
    "eval",
    new string[] { "document.getElementById('login').value = 'admin';" });
webView1.InvokeScript(
    "eval",
    new string[] { "document.getElementById('pass').value = 'password';" });
webView1.InvokeScript(
    "eval",
    new string[] { "document.getElementById('submit').click();" });
相关问题