本文介绍了如何声明硒C#中包含的文本字段的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我有这段代码,我试图断言一个文本字段包含"Post Published",我似乎无法弄清楚
I have this code I'm trying to assert that a text field contains "Post Published" I can't seem to figure it out
string actualvalue = driver.FindElement(By.Id("message")).Text;
actualvalue.Contains("Post published1.");
我不确定声明的位置.
推荐答案
您可以使用对此声明"Assert.IsTrue
string actualvalue = driver.FindElement(By.Id("message")).Text;
Assert.IsTrue(actualvalue.Contains("Post published1."), actualvalue + " doesn't contains 'Post published1.'");
仅在断言失败的情况下才会显示该消息,即actualvalue
不包含"Post published1"
.
The message will be displayed only in case the assertion failed, i.e. actualvalue
doesn't contains "Post published1"
.
这篇关于如何声明硒C#中包含的文本字段的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!