angularjs - 单击不可见的单选按钮
问题描述
我有一个单选按钮,在检查元素时有一个不可见的输入,这就是我看到的
这是 HTML
<rhr-radio-button element-id="criterion-type" model="$ctrl.criterion.criterionTypeRadio" ng-value="$ctrl.CRITERION_TYPE_COST" required="true" label="procurement.evaluation.criterion.options.criterion_type_cost" class="ng-scope ng-isolate-scope" value="COST"><!-- ngIf: $ctrl.horizontal !== 'true' && !$ctrl.readOnly --><div class="radio ng-scope" ng-if="$ctrl.horizontal !== 'true' && !$ctrl.readOnly"><label><input type="radio" class="px ng-pristine ng-untouched ng-empty ng-invalid ng-invalid-required" name="criterion-type" ng-value="::$ctrl.value" ng-model="$ctrl.model" ng-required="$ctrl.innerRequired" ng-disabled="$ctrl.disabled" ng-change="$ctrl.onChange()" value="COST" required="required"> <span class="lbl ng-binding" ng-bind="::($ctrl.label | translate) + ' '">Price </span><!-- ngIf: $ctrl.showHelpText === 'true' --></label></div><!-- end ngIf: $ctrl.horizontal !== 'true' && !$ctrl.readOnly --><!-- ngIf: $ctrl.horizontal === 'true' && !$ctrl.readOnly --><!-- ngIf: $ctrl.readOnly && $ctrl.value == $ctrl.model --></rhr-radio-button>
我已经尝试了一切,例如:
await element.all(by.repeater("ng-scope")).all(by.css("input[type='radio']")).get(0).click();
all(by.tagName('radio.ng-scope')).get(0).click();
element(by.element-id('rhr-radio-button[element-id=criterion-type]')).click();
我怀疑这与我在检查时看不到元素的事实有关。有任何想法吗?
解决方案
试试这个 xpath。
element(By.xpath("//div[@class='col-sm-8']//input[@value='COST' and @type='radio']")).click();
推荐阅读
- c# - 通用存储库中的 Ef 核心包含多对多
- python - Pandas - 将行复制为每一行的新列
- shell - 如何通过 Go 运行此命令?
- reactjs - 将日期值从父级传递给子级会导致子组件中出现奇怪的格式
- android - Android - 如何编辑按钮字符串
- google-bigquery - 如何在 BigQuery 中加入具有特定条件的表?
- c# - 基于动态条件的自动映射器
- azure-devops - azure build pipeline does not start as triggered
- google-chrome-devtools - Remove/hide accessibility info from tooltip in Chrome developer tool
- postgresql - 在 Postgres 中展开行