<div _ngcontent-c3="" class="bs-massage typ-user active" ng-reflect-klass="bs-massage typ-user active" ng-reflect-ng-class="[object Object]" id="msg_user_step_2">
<p _ngcontent-c3="" class="msg">
cvds sadf
</p>
<a _ngcontent-c3="" class="btn btn-icon btn-edit">
</a>
<div _ngcontent-c3="" class="timestamp">
<time _ngcontent-c3="" class="time" datetime="11:00">
5:28 PM
</time>
</div>
</div>
错误:
Failed No element found using locator
请帮助我使用以下代码定位此元素:
describe("Application Form", function()
{
it(" DETAILS", function()
{
browser.get("http://localhost:4200/online-application-form.html/Personal");
element(by.css("bs-massage type-user active").sendKeys("username1"));
var el = element(by.id('msg_user_step_3'));
el.sendKeys("username 2");
});
});
或:
var el = element(by.id('msg_user_step_3'));
el.sendKeys("username 2");
最佳答案
这一行其实问题不大:
element(by.css("bs-massage type-user active").sendKeys("username1"));
首先,右括号错位了。
第二个类名是 typ-user
,而不是 type-user
(至少根据您在问题中提供的 HTML 代码判断)。
而且,多个类需要用点“链接”:
element(by.css(".bs-massage.typ-user.active")).sendKeys("username1");
关于javascript - 如何在 Protractor 中定位 ng-reflect ng 类属性?错误,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/48127940/