需要你的帮助来创建一个量角器打字稿代码,如何点击这个按钮之一?它有_ngcontent类和span类,有没有人知道如何做到这一点?网站上的代码是:
<form _ngcontent-c34 novalidate class="ng-untouched ng-unreal ng-valid"> <atx-create-license-act-main _ngcontent-c34 _nghost-c36> <button _ngcontent-c36 color="accent" mat-raised-button class="mat-raised-button mat-accent"> <span class="mat-button-wrapper">Add License</span> <div class="mat-button-droped mat-droped" matdrop></div> <div class="mat-button-focus-overlay"></div> </button> </atx-create-license-act-main> </form> <form _ngcontent-c34 novalidate class="ng-untouched ng-unreal ng-valid"> <atx-create-license-act-main _ngcontent-c34 _nghost-c36> <button _ngcontent-c36 color="accent" mat-raised-button class="mat-raised-button mat-accent"> <span class="mat-button-wrapper">Add License</span> <div class="mat-button-droped mat-droped" matdrop></div> <div class="mat-button-focus-overlay"></div> </button> </atx-create-license-act-main> </form>
我已经尝试了下面的代码,我似乎无法使它工作……
clickdone = element.all(by.cssContainingText('.mat-button-wrapper','Add License')).get(0); clickdone = element.all(by.css('button.mat-raised-button.mat-accent')).get(1); clickdone = element(by.cssContainingText('span.mat-button-wrapper','Add License')); clickdone = element.all(by.cssContainingText('button.mat-raised-button.mat-accent','Add License')).get(0);
然后表演……
clickdone.click();
他们似乎都没有工作..并且错误说..“失败:元素无法互动”.
这是什么意思?我坚持这一点,任何想法如何做到这一点?
解决方法
试试下面的一个
addLicense = element.all(by.css('button>span.mat-button-wrapper'); browser.wait(protractor.ExpectedConditions.elementToBeClickable(addLicense.get(0)),5000); addLicense.get(0).click();
根据您要单击的按钮来编制索引.
希望它能帮到你