2015-05-28 39 views
1

我正在使用以下代码比较量角器/茉莉花测试用例之一中的2个字符串。getText()的返回值无法与字符串进行比较

emailnotsentmessage.getText().then(function(text) { 
      expect(text).toBe('has not received notification about recent changes to the meeting.'); 
     }); 

其中emailnotsentmessage包含以下文本

[ 'has not received notification about recent changes to the meeting.' ] 

出于某种原因,该字符串比较失败。这两个字符串包含绝对相同的内容。我检查了好几次。我在这里错过了什么吗? 电子邮件未发送消息<span>的内容。

错误跟踪

1) Get to the existing meeting by navigating to the edit meeting page should display the same value which was entered du 
ring create meeting when go into edit meeting 
    Message: 
    Expected [ 'has not received notification about recent changes to the meeting.' ] to equal 'has not received notific 
ation about recent changes to the meeting.'. 
    Stack: 
    Error: Failed expectation 
+1

** [**]似乎是** span **文本的一部分。您正在尝试比较没有** [**] –

+0

感谢您的回复。我尝试** [] **,但我得到同样的错误。 '失败: 1)通过导航到编辑会议页面进入现有会议应显示输入的相同值du 进入编辑会议时环形创建会议 消息: 预期['尚未收到有关最近会议变更“。 ]''''没有收到关于最近会议变更的通知 '。 ]”。 堆栈: 错误:期望失败' – Malik

+0

您是否按照Felix的建议尝试了**数组**? –

回答

3

看起来你emailnotsentmessage阵列,而不是一个字符串。如果你尝试expect(text).toBe(['has not received notification about recent changes to the meeting.']);也许emailnotsentmessage[0]

+0

下面的评论试了一下。但它有相同的结果。 '失败: 1)通过导航到编辑会议页面进入现有会议应显示输入的相同值du 进入编辑会议时环形创建会议 消息: 预期['尚未收到有关最近会议变更“。 ]''''没有收到关于最近会议变更的通知 '。 ]”。 堆栈: 错误:期望失败# 另外我需要比较字符串。不喜欢** emailnotsentmessage [0] ** – Malik

0

找到了解决后面这个问题

我早先使用var emailnotsentmessage = element.all(by.css('css path'));获取引起的问题该元素的原因。它以数组格式返回字符串。相反,我使用element(by.css('css path'));,它返回预期的字符串值。

相关问题