gpt4 book ai didi

javascript - 通过绑定(bind) 'ng-src' 获取元素不起作用,Protractor

转载 作者:搜寻专家 更新时间:2023-11-01 05:31:03 25 4
gpt4 key购买 nike

在 Angular Phone cat 应用程序(第 10 步)中,我无法使用 element(by.binding('bindingName')) Protractor locators

教程链接:Angular phone cat app (step-10, test)

详细信息:

// Working
expect(element(by.css('img.phone')).getAttribute('src'))
.toMatch(/img\/phones\/nexus-s.0.jpg/);

// Not Working
expect(element(by.binding('mainImageUrl')).getAttribute('src'))
.toMatch(/img\/phones\/nexus-s.0.jpg/);
<img ng-src="{{mainImageUrl}}" class="phone">

最佳答案

by.binding 在这种情况下不起作用 by definition .

根据source code ,它只会匹配一个元素,至少,如果元素上有一个 ng-binding 类。

关于javascript - 通过绑定(bind) 'ng-src' 获取元素不起作用,Protractor,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/28202069/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com