gpt4 book ai didi

javascript - webdriverio 'setValue' 到输入字段抛出错误 InvalidElement State

转载 作者:行者123 更新时间:2023-11-29 21:25:04 24 4
gpt4 key购买 nike

InvalidElementState An element command could not be completed because the element is in an invalid state (e.g. attempting to click a disabled element).
invalid element state: Element must be user-editable in order to clear it.

(Session info: chrome=49.0.2623.75) (Driver info: chromedriver=2.21.371459 (36d3d07f660ff2bc1bf28a75d1cdabed0983e7c4),platform=Mac OS X 10.11.4 x86_64) (WARNING: The server did not provide any stacktrace information) [09:49:15]: ERROR Unknown Remote end send an unknown status code. RuntimeError: invalid element state: Element must be user-editable in order to clear it.

截图:

enter image description here

此表单是使用 jquery 文本选择器库实现的。还有其他方法可以设置值吗?

最佳答案

在这种情况下,您应该使用以下方法在 input 字段中设置 setValue :-

WebElement inputEl = driver.findElement(By.xpath("xPath exression"));
inputEl.click();
inputEl.sendKeys(Keys.chord(Keys.CONTROL, "a"), Keys.DELETE, "valuet to set");

如果你想使用JavascriptExecutor,试试下面的方法:-

JavascriptExecutor js = (JavascriptExecutor)driver;
js.executeScript("arguments[0].click();arguments[0].value='';arguments[0].value=arguments[1];",inputEl,"valuet to set");

已编辑..

您需要在设置值之前单击元素以启用此输入(如果它消失了)..

希望这对您有所帮助...:)

关于javascript - webdriverio 'setValue' 到输入字段抛出错误 InvalidElement State,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/37673452/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com