[英]Ingone new line sign and space in typescript and javascript
I am trying to match two sentence in protractor test. 我试图在量角器测试中匹配两个句子。 There is a new line in the second text.
第二个文本中有一个新行。 for this reason the two text is not getting matched in the test case.
因此,两个文本在测试用例中不匹配。 I am getting this message from test output.
我从测试输出中收到此消息。
Expected 'Details user name role' to contain 'Details user
Name
Role
Linie 6'.
Expected :"Details user\nName\nRole" //extra space there
Actual :"Details user Name Role"
my code is like this 我的代码是这样的
await expect(detail.getText()).toContain('Details' + await users.get(user).getText());
how can avoid /n value from there. 如何从那里避免/ n值。 I want to get a plain text from this gettex method
我想从此gettex方法获取纯文本
You can assign original variable to temporary variable and then replace new line with " ". 您可以将原始变量分配给临时变量,然后将新行替换为“”。
Let's say your variable is, 假设您的变量是
var text = "Details user\nName\nRole";
then, 然后,
text.replace("\n"," "); //This will result "Details user Name Role"
Further, You can check whether particular text contains new lines, 此外,您可以检查特定文本是否包含新行,
text.includes("\n")k // true or false
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.