【发布时间】:2020-03-26 08:25:34
【问题描述】:
我正在尝试单击复选框,尤其是 mat-checkbox,但没有成功。
不管我用的是什么类型的定位器,结果都是:
“失败:使用定位器找不到元素:.....”
我能找到的其余页面元素。
我附上 html 和我的 spec.js 的一部分
html:
<mat-checkbox _ngcontent-xmg-c24="" class="checkbox mat-checkbox mat-accent ng-untouched ng-pristine ng-invalid" formcontrolname="acceptTerms" id="mat-checkbox-1">
<label class="mat-checkbox-layout" for="mat-checkbox-1-input">
<div class="mat-checkbox-inner-container mat-checkbox-inner-container-no-side-margin">
<input class="mat-checkbox-input cdk-visually-hidden" type="checkbox" id="mat-checkbox-1-input" tabindex="0" aria-checked="false">
<div class="mat-checkbox-ripple mat-ripple" matripple="">
<div class="mat-ripple-element mat-checkbox-persistent-ripple">
</div>
</div>
<div class="mat-checkbox-frame">
</div>
<div class="mat-checkbox-background">
<svg xml:space="preserve" class="mat-checkbox-checkmark" focusable="false" version="1.1" viewBox="0 0 24 24">
<path class="mat-checkbox-checkmark-path" d="M4.1,12.7 9,17.6 20.3,6.3" fill="none" stroke="white"></path>
</svg>
<div class="mat-checkbox-mixedmark">
</div>
</div>
</div>
<span class="mat-checkbox-label">
<span style="display:none">
</span>
</span>
</label>
</mat-checkbox>
spec.js
it('Registration', async function (){
await homePage.clickRegistration();
await registrationPage.fillEmailAddress(email);
await registrationPage.fillPassword(password);
await registrationPage.fillPassword2(password);
let checkbox = element(by.css("input[formcontrolname=acceptTerms]"));
expect(checkbox).toBeDefined();
await browser.actions().mouseMove(checkbox).click().perform();
});
【问题讨论】:
标签: angularjs protractor automated-tests