Cef Browser Wpf探索dom,查找元素并更改值 [英] Cef Browser Wpf explore the dom, find elements and change values
问题描述
更多信息( 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屋!