Document.getElementById() not available for Chromi

2019-09-09 21:15发布

问题:

When I open a browser as

WebBrowser browser1;

I am able to call

browser1.Document.getElementById();

but when I load the browser as

CromiumWebBrowser browser1;

it says "CefSharp.WinForms.ChromiumWebBrowser does not contain a definition for document".

I have loaded a google sheet on a Chromium browser. I simply want to enter "something" on the first cell.

Can anyone help?

回答1:

After working out to load two browsers in one form in this Q&A, I just had to copy the value and paste it to the focused area on the second browser. That's the best I could do.

Clipboard.SetDataObject((value).ToString(), true);
browser2.Paste();

but now I need to solve another thing. I need to select the next cell on a google sheet. And I have created this Question



回答2:

You can use this:

browser1.ExecuteScriptAsync("document.GetElementById('id1');");