首页 > 解决方案 > 如何使用 Selenium 和 Python 更新 AngularJs 输入标记值?

问题描述

目标输入元素:

input ng-required="$ctrl.isRequired" name="" moment-picker="$ctrl.selectedFormattedDate" ng-model="$ctrl.selectedMoment" value="Fri Mar 27 2020 00:00:00 GMT+0530" ng-disabled="$ctrl.disabled" class="mw-date-picker mw-date-picker-dropdown ng-pristine ng-valid moment-picker-input md-input ng-not-empty ng-valid-required ng-valid-min-date ng-valid-max-date ng-touched" format="L" locale="en" min-view="year" max-view="month" start-view="month" timezone="$ctrl.timezone" today="$ctrl.isTodayHighlighted" change="$ctrl.handleDateChange(newValue, oldValue)" min-date="$ctrl.minDate" max-date="$ctrl.maxDate" tabindex="0" id="input_198" required="required" aria-invalid="false" style="">

我尝试使用 Python 代码更改属性“值”: driver.execute_script("arguments[0].value = '03/10/2019';", element)

此命令会更新前端的值,但单击确定后不会保存更改(确定按钮单击代码没有问题)。我也尝试更改“moment-picker”,但它也没有帮助。有人可以帮我解决使用 Python 的方法吗?

标签: pythonangularjsselenium

解决方案


推荐阅读