gpt4 book ai didi

selenium-webdriver - 使用 selenium 自动化 kendoUI 数字文本框,无需 javascript

转载 作者:行者123 更新时间:2023-12-02 01:17:24 24 4
gpt4 key购买 nike

我有一个场景,我必须自动化一个充满 kendoUI 数字文本框的页面。

我可以使用 xpath 或 id 选择器 定位元素,但是当 selenium 尝试在所述文本框中输入值时,它会收到异常,例如:

ElementNotVisibleException => when tried to click on the said element.

InvalidElementStateException => when tried to input the value using sendKeys

我正在寻找一种无需使用 ExecuteJavascript 接口(interface) 即可自动执行此任务的解决方案。

下面是其中一个文本框的示例 html:

<div class="form-group">
<label for="sheet_width">Page Width<span class="ep-required-label" ng-show="sheet_maintenance_form.sheet_width.$error.required" aria-hidden="false" style="">*</span>
</label>
<span class="k-widget k-numerictextbox ng-dirty ng-valid-parse ng-touched ng-empty ng-invalid ng-invalid-required">
<span class="k-numeric-wrap k-state-default">
<input type="text" class="k-formatted-value ng-pristine ng-untouched ng-valid k-input" title="" tabindex="0" role="spinbutton" aria-valuemin="0" aria-valuemax="999.999" aria-disabled="false" style="display: inline-block;">
<input ng-required="true" kendo-numeric-text-box="sheet_width" k-options="sheet_edit_controller.sheet_field_options" ng-model="sheet_edit_controller.sheet_config.sheet_width" name="sheet_width" id="sheet_width" class="k-input ng-dirty ng-valid-parse ng-touched ng-empty ng-invalid ng-invalid-required" data-role="numerictextbox" role="spinbutton" type="text" aria-valuemin="0" aria-valuemax="999.999" aria-disabled="false" required="required" aria-invalid="true" style="display: none;">
<span class="k-select">
<span unselectable="on" class="k-link k-link-increase" aria-label="Increase value" title="Increase value">
<span unselectable="on" class="k-icon k-i-arrow-60-up"/>
</span>
<span unselectable="on" class="k-link k-link-decrease" aria-label="Decrease value" title="Decrease value">
<span unselectable="on" class="k-icon k-i-arrow-60-down"/>
</span>
</span>
</span>
</span>
</div>

谁能帮我解决这个问题?

非常感谢您的帮助。

最佳答案

这对我有用,可以将框中的值增加 1,但我很欣赏任何其他建议:

Actions actions = new Actions(Browser);
actions.MoveToElement(
Container.FindElement(By.CssSelector("span.k-i-arrow-n"))).Click().Perform()

关于selenium-webdriver - 使用 selenium 自动化 kendoUI 数字文本框,无需 javascript,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/42087166/

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