在Winium中有没有一种方法可以从Windows桌面应用的元素中获取文本?以下脚本将成功打开记事本并键入注释,但随后无法读取文本。
from selenium import webdriver
driver = webdriver.Remote(
command_executor='http://localhost:9999',
desired_capabilities={
"debugConnectToRunningApp": 'false',
"app": r"C:/windows/system32/notepad.exe"
})
window = driver.find_element_by_class_name("Notepad")
window.send_keys("example text")
content = window.text()这将抛出错误selenium.common.exceptions.WebDriverException: Message: NO GET TEXT
发布于 2017-04-11 04:18:17
这似乎起作用了:
edit_element = window.find_element_by_class_name("Edit")
text = edit_element.get_attribute("Name")
print text发布于 2017-07-14 17:19:58
在python中
text = edit_element.get_attribute("Text")c#
text = edit_element.Texthttps://stackoverflow.com/questions/43332166
复制相似问题