如何获取桌面应用程序的xpath、css选择器?

问题描述 投票:0回答:3

我有一个需要使用 python selenium 自动化的应用程序。该应用程序是桌面版本(例如:像桌面上的 Whatsapp(Windows 操作系统),您将在桌面(Windows 操作系统)上运行 Whats 应用程序)因为我们可以获得 xpath 或使用 Chrome、Firefox 或 IE 等的 CSS 我想知道是否有任何工具或应用程序可以用来获取我的应用程序的路径(xpaths,Css),以便我可以获取路径并开始自动化应用程序。

java python selenium selenium-webdriver
3个回答
0
投票

检查:Appium + WinAppDriver:

根据文档,可以运行本机 Windows 应用程序:


0
投票

我个人从未使用过这样的东西,但快速的谷歌搜索给了我这个应用程序:

https://www.inflectra.com/rapise/highlights/xpath-spy-tools.aspx

从表面上看,您需要许可证,但是如果您只进行一次性活动,则可以注册免费试用。


0
投票

WindowsAppDriver 非常适合 Windows 桌面应用程序的 UI 测试,特别是基于 Win32、WinForms 和 WPF 的应用程序。它不适用于较旧的基于 MFC 的应用程序。

对于使用 Electron 或 CEF 浏览器框架构建的桌面应用程序(例如 Visual Studio Code),您可以直接使用 Selenium。它需要传递其他参数,例如“二进制位置”、“CEF 或 Electron 浏览器版本”和远程调试端口(如果您想在特定端口上启动嵌入式浏览器,则需要)。

// Path to the ChromeDriver executable.
System.setProperty("webdriver.chrome.driver", "c:/temp/chromedriver.exe");

ChromeOptions options = new ChromeOptions();
// Path to the CEF executable.
options.setBinary("c:/temp/cef_binary_3.2171.1979_windows32_client/Release/cefclient.exe");
// Port to communicate on. Required starting with ChromeDriver v2.41.
options.addArguments("remote-debugging-port=12345");

WebDriver driver = new ChromeDriver(options);

参考:https://bitbucket.org/chromiumembedded/cef/wiki/UsingChromeDriver.md

© www.soinside.com 2019 - 2024. All rights reserved.