CefSharp - Get Value of HTML Element

后端 未结 5 1142
佛祖请我去吃肉
佛祖请我去吃肉 2021-01-12 10:20

How can I get the value of an HTML element with CefSharp?

I know how to do with this default WebBrowser Control:

Dim Elem As HtmlElement = WebBrowser         


        
5条回答
  •  一整个雨季
    2021-01-12 10:42

    This worked for me. You can modify it by yourself.

    private async void TEST()
    {
        string script = "document.getElementsByClassName('glass')[0]['firstElementChild']['firstChild']['wholeText']";
        JavascriptResponse response = await browser.EvaluateScriptAsync(script);
        label1.Text = response.Result.ToString();
    }
    

    Maybe this can do your job.

    private async void TEST()
    {
        string script = "Document.GetElementByID('id').value";
        JavascriptResponse response = await browser.EvaluateScriptAsync(script);
        string resultS = response.Result.ToString(); // whatever you need
    }
    

提交回复
热议问题