Protractor 量角器检查单选按钮

Protractor 量角器检查单选按钮,protractor,Protractor,我想检查量角器脚本中的单选按钮,html如下所示: <input type="radio" ng-model="relation.type" value="personal" class="ng-valid ng-dirty ng-valid-parse ng-touched" name="7"> 如何在单选按钮列表中编写选择此单选按钮而不是另一单选按钮的表达式?我不想选择的另一个按钮如下所示: <input type="radio" ng-model="relation

我想检查量角器脚本中的单选按钮,html如下所示:

<input type="radio" ng-model="relation.type" value="personal" class="ng-valid ng-dirty ng-valid-parse ng-touched" name="7">

如何在单选按钮列表中编写选择此单选按钮而不是另一单选按钮的表达式?我不想选择的另一个按钮如下所示:

<input type="radio" ng-model="relation.type" value="employee" class="ng-pristine ng-untouched ng-valid" name="8">

因此,两者之间唯一的是“值”。

您可以这样使用

element.all(by.model('relation.type')).get(1).getAttribute('value');
element.all(by.model('relation.type"')).get(2).getAttribute('value');
element.all(by.model('relation.type')).first().getAttribute('value');
element.all(by.model('relation.type"')).last().getAttribute('value');

也请参考量角器文档

类似的内容,也许

    var expectedRadio = element.all(by.model('relation.type'));
    expectedRadio.each((eachRadio) => {
        eachRadio.getAttribute('value').then((valueText) => {
               if (valueText == "personal")
               {
                //Do what you need
               }
        }); 
    });
试试这个:

   try {
        let btn = element(by.xpath('/html/body/app-root/app-login/div[3]/label[2]'));
         browser.executeScript('arguments[0].click()', btn).then(async() => {
            console.log(' Radio Btn has been clicked.');
        });
       } catch (error) {
        console.log('Button is not clickable due ' + error);
      }