我正在使用var orgchart = new getOrgChart(document.getElementById("people"), {
updatedEvent: mouseoverListener,
dataSource: [
{ id: 1, parentId: null, Name: "Amber McKenzie" },
{ id: 2, parentId: 1, Name: "Ava Field" },
{ id: 3, parentId: 1, Name: "Evie Johnson" }]
});
function mouseoverListener() {
var boxes = document.querySelectorAll("[data-node-id]");
for (i = 0; i < boxes.length; i++) {
boxes[i].addEventListener("mouseover", function () { alert("hovered node ID is " + this.getAttribute("data-node-id")) });
}
}
mouseoverListener();
,我想从其中一个属性中选择文字。但是,我无法弄清楚如何访问它。
pywinauto
我想访问值import pywinauto
pwa_app = pywinauto.application.Application()
path = r'C:\Users\me\Cisco\Cisco AnyConnect Secure Mobility Client\vpnui.exe'
pwa_app.start(path)
w_handle = pywinauto.findwindows.find_windows(title=u'Cisco AnyConnect Secure Mobility Client', class_name='#32770')[0]
window = pwa_app.window_(handle=w_handle)
window.SetFocus()
window.print_control_identifiers(2)
Control Identifiers:
Dialog - 'Cisco AnyConnect Secure Mobility Client' (L1421, T493, R1854, B690)
['Cisco AnyConnect Secure Mobility Client', 'Cisco AnyConnect Secure Mobility ClientDialog', 'Dialog']
child_window(title="Cisco AnyConnect Secure Mobility Client", class_name="#32770")
|
| #32770 - '' (L1441, T535, R1834, B647)
| ['#32770', 'VPN:#32770']
| child_window(class_name="#32770")
|
| Static - 'VPN:' (L1527, T548, R1551, B561)
| ['Static', 'VPN:Static', 'VPN:', 'Static0', 'Static1']
| child_window(title="VPN:", class_name="Static")
|
| ComboBox - 'Brock AppDMZ VPN' (L1527, T594, R1719, B615)
| ['ComboBox', 'Connected to Brock AppDMZ VPN.ComboBox', 'VPN:ComboBox', 'ComboBox0', 'ComboBox1', 'Connected to Brock AppDMZ VPN.ComboBox0', 'Connected to Brock AppDMZ VPN.ComboBox1']
| child_window(title="Brock AppDMZ VPN", class_name="ComboBox")
|
| Edit - 'Brock AppDMZ VPN' (L1530, T597, R1699, B612)
| ['Connected to Brock AppDMZ VPN.Edit', 'Edit']
| child_window(title="Brock AppDMZ VPN", class_name="Edit")
|
| ComboBox - '' (L1527, T594, R1719, B615)
| ['ComboBox2', 'Connected to Brock AppDMZ VPN.ComboBox2']
| child_window(class_name="ComboBox")
以确定我是否已连接到我的VPN,但此库中的文档并不是非常清楚如何执行此操作。
答案 0 :(得分:1)
print_control_identifiers()
的输出不完整(此处未列出目标文本标签,窗口上有3个静态文本),但幸运的是我的PC上有相同的Cisco VPN客户端。问题是这个&#34;静态&#34;文字是动态的。 :)有两种方法可以处理这种情况。
1)只需创建一个窗口规范并检查该窗口是否存在:
connected_label = window.child_window(title="Connected to Brock AppDMZ VPN.", class_name="Static")
# default timeout is pywinauto.timings.Timings.window_find_timeout (5 sec.)
if connected_label.exists(timeout=10):
pass # do whatever you want
2)依赖于此静态文本的编号,并在每次需要连接状态时检查其文本:
label = window.child_window(class_name="Static", found_index=1).wait('exists')
if label.window_text() == "Connected to Brock AppDMZ VPN.":
pass # do whatever you want
答案 1 :(得分:0)
label = window.child_window(class_name="Static", found_index=1).wait('exists')
print label.get_value()
试试这个,<element>.get_value()
希望这能为您提供所需的文字。