首页 > 解决方案 > OpenQA.Selenium.ElementNotInteracable - 无法到达元素

问题描述

我不知道为什么我的代码看不到第二个输入。将文本添加到第一个输入时成功接收OpenQA.Selenium.ElementNotInteracable: Element input.k-formatted-value.ng-pristine.ng-untouched.ng-valid.k-input is not reachable by keyboard错误。

By inputOneSrc = By.CssSelector("input.invalid");
By inputTwoSrc = By.CssSelector("input.k-formatted-value.ng-pristine.ng-untouched.ng-valid.k-input");

IWebElement inputFirst = driver.findElement(inputOneSrc);
IWebElement inputSecound = driver.findElement(inputTwoSrc);

inputFirst.SendKeys("abc");
inputSecound.SendKeys("cba");

在将文本发送到inputFirst后,我​​尝试使用Clear() ,但仍然无法将文本添加到第二个输入。我认为这个文本以某种方式隐藏,因为我可以看到它使用:

inputFirst.GetAttribute("value");
inputSecound.GetAttribute("value");

但不能只使用 Text()。您知道如何解决它以查看输入中的文本吗?

<input type="text" class="k-formatted-value ng-pristine ng-untouched ng-valid k-input" title="" tabindex="0" role="spinbutton" aria-valuemin="-999999999999999" aria-valuemax="999999999999999" aria-title="" aria-valuenow="" aria-disabled="false" aria-readonly="false" style="display: inline-block;">
<input next-focus="" kendo-numeric-text-box="c.numeric" k-options="numericOptions" ng-model="c.Value" style="display: none;" ng-class="{'flow-required': !c.AllowEmpty}" required="" class="ng-pristine k-input ng-invalid ng-invalid-required flow-required invalid ng-touched" data-role="numerictextbox" role="spinbutton" type="text" aria-valuemin="-999999999999999" aria-valuemax="999999999999999" aria-valuenow="" aria-disabled="false" aria-readonly="false">

<input type="text" class="k-formatted-value ng-pristine ng-untouched ng-valid k-input" title="" tabindex="0" role="spinbutton" aria-valuemin="-999999999999999" aria-valuemax="999999999999999" aria-title="" aria-valuenow="" aria-disabled="false" aria-readonly="false" style="display: inline-block;">
<input next-focus="" kendo-numeric-text-box="c.numeric" k-options="numericOptions" ng-model="c.Value" style="display: none;" ng-class="{'flow-required': !c.AllowEmpty}" required="" class="ng-pristine k-input ng-invalid ng-invalid-required flow-required invalid ng-touched" data-role="numerictextbox" role="spinbutton" type="text" aria-valuemin="-999999999999999" aria-valuemax="999999999999999" aria-valuenow="" aria-disabled="false" aria-readonly="false"><span class="k-select">

标签: c#selenium-webdriver

解决方案


推荐阅读