使用robotframework-selenium时如何测试空白文本字段?
将 robotsframework-seleniumlibrary 与 TSV 文件一起使用时,如何为文本字段指定空白/空值?例如,我有以下内容:
Textfield Value Should Be identifier=name1 Chris
Textfield Value Should Be identifier=name2
我想测试 name2 是否为空。我尝试将其留空(这会返回有关参数数量不正确的消息。我尝试过“”,它查找一对引号,而''输入单引号,而selenium似乎会查找该
How can I specify blank/empty value for a text field when using the robotframework-seleniumlibrary with a TSV file? For example, I have the following:
Textfield Value Should Be identifier=name1 Chris
Textfield Value Should Be identifier=name2
I want to test that name2 is blank. I have tried leaving it blank (which returns a message about an incorrect number of arguments. I have tried "", which looks for a pair of quotes, and '' which enters a single quote, and selenium seems to look for that
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(3)
您可以使用单个反斜杠
\
或特殊变量${EMPTY}
在测试数据中创建空字符串。用户指南包含详细信息:机器人框架用户指南。You can use either a single backslash
\
or special variable${EMPTY}
to create an empty string in the test data. User guide has the details: Robot Framework User Guide.是的,
${EMPTY}
是一个内置变量。有很多示例,请参阅此处的示例
Yes,
${EMPTY}
is a built in variable.There are many examples, see an example here
${EMPTY}
对于空白值很有用,但令人惊讶的是,它不适用于空值。我找到了我要找的东西。我正在验证的字段的 value 属性没有值,我想验证它。它返回
''
作为值,但在使用${EMPTY}
时却找不到''''
。这是一件小事,但最终解决了我需要的问题,所以这取决于你想要验证的内容。${EMPTY}
is good for a blank value but, surprisingly, it didn't work for an empty value.I found what I was looking for. The field I was verifying had no value in its value attribute and I wanted to verify it. It was returning
''
as the value and when using${EMPTY}
it couldn't find''''
instead. Such a minor thing but ended up solving what I needed, so it depends what you're seeking to verify.