我在这里找到了关于 devtools-protocol 问题跟踪器的答案https://github.com/ChromeDevTools/devtools-protocol/issues/66
完整的工作解决方案可以在这里找到:
https ://github.com/cezarypiatek/Tellurium/blob/master/Src/MvcPages/SeleniumUtils/ChromeRemoteInterface/ChromeRemoteInterface.cs
private long GetChromeNodeId(IWebElement inputElement)
{
driver.ExecuteScript(@"(function(fileInput){
window.__tellurium_chromerinode = fileInput;
})(arguments[0])", inputElement);
var evaluateResponse = SendCommand("Runtime.evaluate", new Dictionary<string, object>
{
["expression"] = "window.__tellurium_chromerinode"
});
driver.ExecuteScript(@"(function(fileInput){
delete window.__tellurium_chromerinode;
})()");
var remoteObjectId = evaluateResponse.GetValue<string>("result.objectId");
var rquestNodeResponse = SendCommand("DOM.requestNode", new Dictionary<string, object>
{
["objectId"] = remoteObjectId
});
return rquestNodeResponse.GetValue<long>("nodeId");
}