简体   繁体   English

Javascript Windows UI 自动化

[英]Javascript Windows UI Automation

In VB.NET, I can automate application installs using Windows UI Automation.在 VB.NET 中,我可以使用 Windows UI 自动化自动安装应用程序。 Is it possible to do this in javascript?是否可以在 javascript 中执行此操作? vbscript would also be acceptable but javascript is preferable. vbscript 也可以接受,但 javascript 更可取。

There a JavaScript tool to automation Windows UI application, LeanRunner Lite, can run with Node.js language.有一个自动化 Windows UI 应用程序的 JavaScript 工具 LeanRunner Lite 可以使用 Node.js 语言运行。 It can be installed from Windows Store它可以从Windows 应用商店安装

It is possible using Appium.可以使用 Appium。 You may already know how to use Appium in Node.js/JavaScript.您可能已经知道如何在 Node.js/JavaScript 中使用 Appium。

Using NPM to download the Appium package, which is described here:使用NPM下载Appium包,描述如下:

Appium NPM Package Appium NPM 包

It already contains the Windows App Driver, which is described below:它已经包含 Windows 应用程序驱动程序,如下所述:

https://github.com/appium/appium/blob/HEAD/docs/en/drivers/windows.md https://github.com/appium/appium/blob/HEAD/docs/en/drivers/windows.md

Another alternative is to use the Win-App-Driver directly, as described below: https://github.com/appium/appium-windows-driver另一种选择是直接使用 Win-App-Driver,如下所述: https : //github.com/appium/appium-windows-driver

For Windows UI automation, try windows-app .对于 Windows UI 自动化,请尝试windows-app For example, to use the calculator do this:例如,要使用计算器,请执行以下操作:

const windowsApp = require("windows-app")
 
const {select, close} = await windowsApp("Microsoft.WindowsCalculator_8wekyb3d8bbwe!App") // Calculator app
 
await select.name_("One").click()
await select.name_("Plus").click()
await select.name_("Two").click()
await select.name_("Equals").click()
const result = Number((await select.accessibilityId("CalculatorResults").getText()).replace("Display is", ""))
 
console.log(`The result of 1 + 2 is ${result}`)
//=> "The result of 1 + 2 is 3"
 
await close()

JavaScript 仅限于与 DOM 和远程服务器的交互(相同的源策略加上服务器定义的例外),您不能像那样在客户端机器上安装软件。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM