Warning: file_get_contents(/data/phpspider/zhask/data//catemap/3/xpath/2.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Selenium 如何定位桌面应用程序的XPATH_Selenium_Xpath_Desktop Application_Winappdriver_Winium - Fatal编程技术网

Selenium 如何定位桌面应用程序的XPATH

Selenium 如何定位桌面应用程序的XPATH,selenium,xpath,desktop-application,winappdriver,winium,Selenium,Xpath,Desktop Application,Winappdriver,Winium,如何在桌面应用程序中查找元素的XPath 我正在使用Inspect工具获取元素的名称。如何从Inspect工具创建Xpath?我可以在XPath中使用LegacyIAccessible.ChildId来定位元素的位置吗 'How found: Mouse move (-1648,104)' 'Name: "Compare"' 'ControlType: UIA_ButtonControlTypeId (0xC350)' 'LocalizedControlType: "button"' '

如何在桌面应用程序中查找元素的XPath

我正在使用Inspect工具获取元素的名称。如何从Inspect工具创建Xpath?我可以在XPath中使用LegacyIAccessible.ChildId来定位元素的位置吗

'How found: Mouse move (-1648,104)'
'Name:  "Compare"'
'ControlType:   UIA_ButtonControlTypeId (0xC350)'
'LocalizedControlType:  "button"'
'BoundingRectangle: {l:-1695 t:94 r:-1587 b:116}'
'IsEnabled: true'
'IsOffscreen:   false'
'IsKeyboardFocusable:   true'
HasKeyboardFocus:   false
'AccessKey: "Alt, C, CP"'
'ProcessId: 22040'

'IsPassword:    false'
'HelpText:  ""'
'IsDialog:  false
'LegacyIAccessible.ChildId: 3'
'LegacyIAccessible.DefaultAction:   "Press"'
'LegacyIAccessible.Description: "Compare the Controller Strategy with the PC"'

您可以使用appium获取当前会话。一旦appium获取了当前窗口,您就可以使用is来查找xpath。我正在使用appium

-Open Appium 
-go to file  
-New session window 
-attach to session 
-paste the session (make sure your app is in debugging mode and your session    is active) 
-appium will grab the current window of the desktop app

使用WinAppDriver UI记录器,它在WinAppDriver GitHub存储库中可用。
当UIR运行时,它生成XPath以到达鼠标悬停的任何UI元素。

XPath用于定位XML/XHTML DOM等内部的位置/元素,本质上是一个网页或文件。不适用于传统的桌面应用程序。是的,你是对的。它用于查找web元素。它也可以在用于桌面应用程序的winium中使用。请参阅:@ou_ryperd Winappdriver支持一种树形结构的windows桌面自动化方法。可以使用XPath选择器。@sphennings我不知道。您需要使用XPath选择器吗?我发现,使用AutomationID可以对桌面应用程序进行更可靠、更快的测试。谢谢。我有Win应用程序驱动程序Ui记录器。但不确定如何生成XPath。我可以用任何组合来创建它吗?我没有看到名为xpath的标记。