[英]How to disable text field of desktop application which has no Id and Name
I'm using winiumDriver for desktop application. 我正在将winiumDriver用于桌面应用程序。 I want to disable textfield once value filled in the text field. 我想禁用一次文本字段值填充文本字段。
//open desktop application
WiniumDriver driver = null;
DesktopOptions option = new DesktopOptions();
option.setApplicationPath("Desktop application path");
driver = new WiniumDriver(new URL("http://localhost:9999"), option);
WebElement window = driver.findElementByClassName("Qt5QWindowIcon");
List<WebElement> list = window.findElements(By.className(""));
//Send values to fields
list.get(10).sendKeys("USERNAME");
//javaScript code to disable
JavascriptExecutor javascript = (JavascriptExecutor) driver;
String todisable = "document.getElementsByName('')[10].setAttribute('disabled', '');";
javascript.executeScript(todisable);
//getting this eception //得到这个信号
Exception in thread "main" org.openqa.selenium.WebDriverException: Unknown script command ' document.getElementsByClassName('')[10].setAttribute('disabled', '');'. 线程“主”中的异常org.openqa.selenium.WebDriverException:未知脚本命令'document.getElementsByClassName('')[10] .setAttribute('disabled','');')。 See https://github.com/2gis/Winium.Desktop/wiki/Command-Execute-Script for supported commands. 有关受支持的命令,请参见https://github.com/2gis/Winium.Desktop/wiki/Command-Execute-Script 。 (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 (警告:服务器未提供任何堆栈跟踪信息)命令持续时间或超时:12毫秒内部版本信息:版本:'2.48.2',修订版:'41bccdd10cf2c0560f637404c2d96164b67d9d67',时间:'2015-10-09 13:08:06'系统信息:主机:'DESKTOP-JL5UPRJ',ip:'192.168.0.112',操作系统名称:'Windows 10',os.arch:'amd64',os.version:'10 .0',java.version:'1.8 .0_131'驱动程序信息:org.openqa.selenium.winium.WiniumDriver
Desktop applications don't use JavaScript. 桌面应用程序不使用JavaScript。 Winium's implementation for executeScript specifically support few proprietary commands as described in the link in the error message, instead of actually executing JavaScript. Winium的executeScript实现特别支持错误消息链接中所描述的少数专有命令,而不是实际执行JavaScript。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.