获取浏览器页面含有的iframe个数,循环iframe当地址满足需要的条件是执行js代码注入
System.Collections.Generic.List<long> l = chrbro.GetBrowser().GetFrameIdentifiers();
for (int i = 0; i < l.Count; i++)
{
ActiveFrame = chrbro.GetBrowser().GetFrame(l[i]);
if (ActiveFrame.Url.StartsWith("https://baidu.com"))
{
//向浏览器中注入js代码
ActiveFrame.ExecuteJavaScriptAsync("var tabs = document.getElementsByClassName('classname'); ", ActiveFrame.Url, 0);
Thread.Sleep(5000);
break;
}
}