Cef Browser Wpf探索dom,查找元素并更改值 [英] Cef Browser Wpf explore the dom, find elements and change values

查看:339
本文介绍了Cef Browser Wpf探索dom,查找元素并更改值的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

更多信息( CefSharp使用浏览器登录名加载页面)。
我实现了 IRequestHandler 接口和其他方法,尤其是 GetAuthCredentials ,其中显示了一个对话框并进行恢复用户和密码,并将其传递给事件处理程序。
现在我想访问dom,在那里我得到几个 frameset 与不同的 frame ,对一个框架感兴趣,我知道名称属性。
在此框架中,我需要获取不同类型的 input 的列表选择等...
在我的应用程序中,我有一个按钮,用于设置不同的元素的值显示在显示的页面上。
问题是我看不到获取文档框架集合等的任何方式。 ..

Further to a post (CefSharp load a page with browser login). I implemented the IRequestHandler interface and the different methods, particularly the GetAuthCredentials where I show a dialog and recover user and password and passing it to the event handler. Now I want to access to the dom where I get several frameset with differents frames and I'm interested in one frame which I know the name Atribute. Inside this frame I need to get list of different type of input , select etc... In my app I have a button which I use to set values of the different elements depending if they are present on the displayed page. PROBLEM is I don't see any way of getting the document, the frames collection etc....

推荐答案

CefSharp 不公开底层的 DOM ,不太可能看到 http://magpcss.org/ceforum/viewtopic.php?f=6&t=10652&p=19533#p16750

CefSharp doesn't expose the underlying DOM, and is unlikely to see http://magpcss.org/ceforum/viewtopic.php?f=6&t=10652&p=19533#p16750

您最好的选择是使用 EvaluateScriptAsync JavaScript绑定

Your best bet is to use EvaluateScriptAsync and a combination of Javascript Binding

https://github.com/cefsharp/CefSharp/wiki/Frequently-asked-questions#2-how-do-you-call-a-javascript-method-that-return -a-结果
https://github.com/cefsharp/CefSharp/wiki/Frequently-asked-questions#3-how-do-you-expose-a-net-class-to-javascript

如果您绝对必须具有 DOM 访问权限,并且无法发明解决方案的方法,则 CefGlue 对您来说可能是一个更好的选择。 (我应该指出, DOM 只能在 Render 进程中进行访问,因此需要通过 IPC 传递给浏览器进程,因此这不是一件简单的任务。

If you absolutely must have DOM access and cannot invent your way to a solution then CefGlue might be a better choice for you. (I should point out that the DOM can only be accesses in the Render process, and as such calls needed to be passed to the Browser process though IPC, so it isn't a trivial task).

这篇关于Cef Browser Wpf探索dom,查找元素并更改值的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆