Selenium 当预期消息的mora超过一行时,量角器ExpectedConditions.TextToBePresentElement返回false
我面临量角器的新问题, 当我尝试使用此selenium方法时: ExpectedConditions.TextToBePresentElement 它返回false,因为my元素返回以下消息: 连接不可用。 此时无法连接到设备 这是我期望的字符串: 消息:连接不可用。\n此时无法连接到设备 那么我的方法调用是:Selenium 当预期消息的mora超过一行时,量角器ExpectedConditions.TextToBePresentElement返回false,selenium,protractor,Selenium,Protractor,我面临量角器的新问题, 当我尝试使用此selenium方法时: ExpectedConditions.TextToBePresentElement 它返回false,因为my元素返回以下消息: 连接不可用。 此时无法连接到设备 这是我期望的字符串: 消息:连接不可用。\n此时无法连接到设备 那么我的方法调用是: browser.wait(ExpectedConditions.textToBePresentInElement(element, message), 160000, 'The expe
browser.wait(ExpectedConditions.textToBePresentInElement(element, message), 160000, 'The expected text is not present in the UI');
也许有人能帮我解决这个问题也许这不是最好的方法,但它会解决你的问题。只需将预期消息替换为没有
\n
的消息即可:
browser.wait(ExpectedConditions.textToBePresentInElement(element, message.replaceAll("\\n", " ")),
160000, 'The expected text is not present in the UI');
这实际上是最好的办法;另一种方法是搜索文本中需要的关键字,如“连接不可用”,然后假设消息的其余部分是正确的,或者搜索“设备”。但是这些需要不同的匹配器,而不是另一台macthers的
texttobepresentElement
?你能给我举个例子吗?谢谢