我尝试在devtools控制台document.getElementById('global-files-button').click()
中执行以下脚本,并显示文件对话框。
但是当我尝试通过ExecuteScriptAsync执行此清单时,什么也没发生。
chrome.GetMainFrame()
.ExecuteJavaScriptAsync("document.getElementById('global-files-button').click();");
private void button4_Click(object sender, EventArgs e)
{
settings = new CefSettings();
Cef.Initialize(settings);
chrome = new ChromiumWebBrowser("https://imgur.com/upload");
this.panel1.Controls.Add(chrome);
chrome.Dock = DockStyle.Fill;
chrome.AllowDrop = true;
}
private void button5_Click(object sender, EventArgs e)
{
chrome.GetMainFrame().ExecuteJavaScriptAsync("document.getElementById('global-files-button').click();");
}