gpt4 book ai didi

angularjs - Protractor getAttribute ('value' )返回 null

转载 作者:行者123 更新时间:2023-12-02 00:16:14 25 4
gpt4 key购买 nike

我对 Protractor 相当陌生,并且在从仅在满足特定条件时显示的错误框中获取文本时遇到一些困难。

我确信这只是一个语法问题。下面是我用来尝试获取框中显示的“文本”并将其与预设静态字符串进行比较的行。

expect(element(by.css('[ng-switch-default=""]')).getAttribute('value')).toEqual(expected_error_message);

我收到回复消息:

Message: Expected null to equal 'User with login <a href="https://stackoverflow.com/cdn-cgi/l/email-protection" class="__cf_email__" data-cfemail="7a0e1f090e4242484d49434b3a1d171b131654191517" rel="noreferrer noopener nofollow">[email protected]</a>' already exists.'

所以基本上没有什么可以比较字符串,因为“getAttribute('value') 应该获取的值返回 null”。

我引用的 HTML block 位于下面:

<div ng-class="config.message" ng-switch="" on="toaster.bodyOutputType"         class="toast-message"><div ng-switch-default="" class="ng-binding">User with login  '<a href="https://stackoverflow.com/cdn-cgi/l/email-protection" class="__cf_email__" data-cfemail="c0b4a5b3b4f8f8f2f7f3f9f180a7ada1a9aceea3afad" rel="noreferrer noopener nofollow">[email protected]</a>' already exists.</div></div>

最佳答案

看起来您的消息不是属性,而是 div 的文本。尝试:

expect(element(by.css('[ng-switch-default=""]')).getText()).toEqual(expected_error_message);

关于angularjs - Protractor getAttribute ('value' )返回 null,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/28120205/

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