I need to write windows app automation script using winium with JavaScript. I've done this using Java as lots of help and material is available for references. But I need to do the same in JavaScript and I don't know the equivalent APIs of winium in JavaScript binding.
Constraints below -
Tool of choice - winium
Language of choice - JavaScript
Application - any Windows app like. Notepad
Well here's how i was able to do it with JS (selenium + winium.desktop.driver). Hope this will be useful.
Note : In case you get following error consider downgrading the selenium-webdriver to 2.45.0.
Error - UnsupportedOperationError: 'css selector' is not valid or implemented searching strategy.
Code snippet :
"use strict";
const {Builder, By, Key, until} = require('selenium-webdriver');
(async function example() {
let driver = await new Builder().usingServer('http://localhost:9999')
.withCapabilities({
"app": "C:\\WINDOWS\\system32\\notepad.exe",
"platformName": "Windows",
"deviceName": "WindowsPC"
})
.forBrowser('windows')
.build();
try {
await sleep(2000).then(function(){});
await driver.findElement(By.name('Text Editor')).sendKeys('123');
}
finally {
console.log('Killed..');
await driver.quit();
}
})();
function sleep(ms) {
return new Promise(resolve => setTimeout(resolve, ms));
}