【问题标题】:Getting HTML element handle from MATLAB从 MATLAB 获取 HTML 元素句柄
【发布时间】:2015-11-11 08:25:29
【问题描述】:

我需要将 MATLAB 连接到网页,然后获取一些数据,在网页中填写一些文本并运行一些 java 脚本(例如按下按钮)。根据答案 Running a JavaScript command from MATLAB to fetch a PDF file,我可以打开一个页面并运行一个脚本,但是我在“webbrowser 对象”中找不到元素句柄(例如文本字段)来获取数据并更改它们的值。

谢谢。

例如:

url='www.web.com';

%    Open web page
import com.mathworks.mde.desk.*;
wb=com.mathworks.mde.webbrowser.WebBrowser.createBrowser;
wb.setCurrentLocation(url);

%    Here I should enter some text in a field. 
%    I have the field name from inspect element window,
%    But I can not find its handle reference to change its value.

%   Execute script
wb.executeScript('javascript:__doPostBack("ctl00$ContentPlaceHolder1$btn_find","")')

【问题讨论】:

  • 请分享您正在使用的代码,也许有人可以帮助您。
  • 提供了一个例子。 @MattiasLindberg

标签: java html matlab webbrowser-control


【解决方案1】:

最后用这个方法没找到解决方案,但是用com server找到了解决方案:

oIE = actxserver('internetexplorer.application');
oIE.Navigate('http://www.page.com/');
oH=oDoc.getElementById('IDName');
set(oH,'value','Test')

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 2011-04-25
    • 1970-01-01
    • 2012-09-26
    • 2011-09-20
    • 1970-01-01
    • 2014-05-22
    • 1970-01-01
    相关资源
    最近更新 更多