I am currently using WiniumDriver to automate a desktop application. My goal is to disable a text field once a value has been entered into it.
// Launch the desktop application
WiniumDriver driver = null;
DesktopOptions option = new DesktopOptions();
option.setApplicationPath("Path to desktop application");
driver = new WiniumDriver(new URL("http://localhost:9999"), option);
WebElement window = driver.findElementByClassName("Qt5QWindowIcon");
List<WebElement> list = window.findElements(By.className(""));
// Enter values into fields
list.get(10).sendKeys("USERNAME");
// JavaScript code to disable the text field
JavascriptExecutor javascript = (JavascriptExecutor) driver;
String todisable = "document.getElementsByName('')[10].setAttribute('disabled', '');";
javascript.executeScript(todisable);
// Encountering this exception
Exception in thread "main" org.openqa.selenium.WebDriverException: Unknown script command ' document.getElementsByClassName('')[10].setAttribute('disabled', '');'. See https://github.com/2gis/Winium.Desktop/wiki/Command-Execute-Script for supported commands. (WARNING: The server did not provide any stacktrace information) Command duration or timeout: 12 milliseconds Build info: version: '2.48.2', revision: '41bccdd10cf2c0560f637404c2d96164b67d9d67', time: '2015-10-09 13:08:06' System info: host: 'DESKTOP-JL5UPRJ', ip: '192.168.0.112', os.name: 'Windows 10', os.arch: 'amd64', os.version: '10.0', java.version: '1.8.0_131' Driver info: org.openqa.selenium.winium.WiniumDriver