【发布时间】:2021-03-18 23:28:46
【问题描述】:
<div class="MuiGrid-root jss48321 MuiGrid-item MuiGrid-grid-xs-12 MuiGrid-grid-sm-3 MuiGrid-grid-md-3 MuiGrid-grid-lg-3 MuiGrid-grid-xl-3">
<h4 class="MuiTypography-root jss48324 MuiTypography-h4">Decks</h4>
<button class="MuiButtonBase-root MuiFab-root jss48323 MuiFab-sizeSmall MuiFab-primary" tabindex="0" type="button" aria-label="add" title="Add">
<span class="MuiFab-label">
<svg class="MuiSvgIcon-root" focusable="false" viewBox="0 0 24 24" aria-hidden="true">
<path d="M19 13h-6v6h-2v-6H5v-2h6V5h2v6h6v2z"></path>
</svg>
</span>
<span class="MuiTouchRipple-root"></span>
</button></div>
由于是react js应用,所以我加了
browser.waitForAngularEnabled(false);
这里我想点击添加图标 (+)
我的测试脚本:
describe('IEC', function () {
it('Login', function () {
browser.waitForAngularEnabled(false);
browser.get('cannot provide the url since it requires VPN');
element(by.css('input[type="text"]')).sendKeys('12345');
element(by.css('input[type="password"]')).sendKeys('Pwd');
element(by.buttonText('Login')).click();
element(by.css('button[title="Add"]')).click();
});
});
输出:
失败:使用定位器找不到元素:By(css selector, button[title="Add"])
我该如何解决这个问题?#
【问题讨论】:
-
你添加了显式等待
-
我同意上述评论,您需要创建自己的显式等待。所以像浏览器一样。等待DOM中的元素(我认为是isPresent)
-
你需要提供完整的代码 sn-p 而不仅仅是你认为它不起作用的那一行
-
嗨@SergeyPleshakov 现在添加了完整的代码。请检查。
-
嗨@PDHide,我尝试了显式等待,它奏效了。非常感谢
标签: reactjs jasmine protractor