首页 > 解决方案 > 单击不可见的单选按钮

问题描述

我有一个单选按钮,在检查元素时有一个不可见的输入,这就是我看到的

悬停时,代码没有显示

这是 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' &amp;&amp; !$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) + '&nbsp;'">Price&nbsp;</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();

我怀疑这与我在检查时看不到元素的事实有关。有任何想法吗?

标签: angularjsseleniumprotractorautomated-tests

解决方案


试试这个 xpath。

 element(By.xpath("//div[@class='col-sm-8']//input[@value='COST' and @type='radio']")).click();

推荐阅读