简体   繁体   English

如何禁用没有ID和名称的桌面应用程序的文本字段

[英]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.

相关问题 如果文本字段具有值,请禁用选择框 - Disable select boxes if text field has a value 将相应的文本字段值传递给具有相同 id 的函数 - passing corresponding text-field values into the function which has the same id's 当字段没有ID但有名称时,如何设置文本输入字段的值。 我无法使用document.getElementById - How do I set the value of a text input field when the field does not have an id but it has a name. I can't use document.getElementById 如果输入字段通过 ID 或类包含内容,则禁用输入字段 - Disable input field if it has contents via ID or class 禁用以角度显示未来月份的输入文本字段 - Disable input text field which are coming on future month in angular 如何在vanilla js中选择一个在id中具有特定文本的选择类型对象? - How to select a select type object which has certain text in the id in vanilla js? 如何禁用JavaScript中的文本字段和组合框 - how to disable text field and combo box in javascript 如果存在值,如何禁用文本字段或输入? - How to disable text field or input if a value is present? 如何识别点击了哪个按钮? 如果该按钮进入并循环(while)并且具有 id 和 name = “enviar” 。 我需要知道点击了哪一个按钮 - how identify which button was clicked? if that button in and loop(while) and has id and name = “enviar” . I need to know which one button was clicked 如何在空白的文本/数字字段禁用按钮 - How to disable a button at an empty text/number field
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM