使用Appium和WinAppDriver获取元素的所有可用属性

时间:2020-11-10 09:17:59

标签: python attributes appium winappdriver

我正在努力获取element的所有可用属性。我会解释一下。 我正在使用WinAppDriver + Appium + Python创建自动化。我想以某种方式加载一个特定元素的所有可用属性。例如,属性Legacy | AccessiblePattern.Value。 当我使用appium方法driver.find_element_by_name('DataGridView').get_attribute('Legacy|AccessiblePattern.Value')时,它将返回None,这意味着找到了元素,但该属性不存在。 但是,当我使用method driver.find_element_by_name('DataGridView').get_attribute('LegacyValue')时,它将按预期返回属性的内容。我的问题是,如何才能获得所有可用的属性,或者至少在哪里可以找到Inspector.exe中的可见属性名称的链接 ('Legacy | AccessiblePattern.Value') 实际名称,可在Python中用于与元素('LegacyValue')

一起使用

如果您很烦心,我是如何找到该元素属性的准确名称的,所以我很幸运地猜到了。我刚刚发现WinAppDriver的第46行有一个测试,内容为:Assert.IsTrue(element.GetAttribute("LegacyName").StartsWith("Alarm")); // Shows as Legacy|Accessible.Name in inspect.exe and when I used 'LegacyValue', it WORKED!

https://github.com/microsoft/WinAppDriver/blob/master/Tests/WebDriverAPI/ElementAttribute.cs#L46 但是这种猜测要花很多时间。有人可以帮我吗?

感谢米洛斯拉夫

0 个答案:

没有答案