OpenQA.Selenium.ElementNotInteracable - 无法到达元素

时间:2018-05-02 19:12:57

标签: c# selenium-webdriver

我不知道为什么我的代码没有看到secound输入。向第一个输入添加文本成功收到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(),但仍然无法向secound输入添加文本。我认为这个文本是隐藏的,因为我可以使用:

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">

0 个答案:

没有答案