QTP使用正则表达式动态匹配对象文本
假设我们正在尝试匹配 SSN,因此正则表达式为:d{9}。但是,如果在运行时我想让第三位数字与 3 匹配怎么办?因此正则表达式将为 d{2}3d{6}。
我知道在 QTP 中,您可以使用正则表达式来匹配对象存储库中对象的文本属性,但是如何在 QTP 代码中更改该正则表达式?
感谢您的帮助!
Let's say we're trying to match SSNs, so the regular expression would be: d{9}. But what if, at run time, I wanted to have, say, the third digit match to 3? So the regex would be d{2}3d{6}.
I know that in QTP, you can use regex to match the text property of an object in the Object Repository, but how do I change that regex in QTP code?
Thanks for your help!
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
您可以使用
SetTOProperty
更改存储库中的属性值,这会更改当前运行的值,但不会更改下一次测试运行的值。它还更改存储的测试对象中的值,而不是正在测试的应用程序中相应控件中的值(要从应用程序中获取当前值,请使用 GetROProperty ,没有 SetROProperty ) )。请注意,虽然您可以更改该值,但无法更改它是否为正则表达式(上述情况仅在
5
的text
属性已定义为使用时才有效正则表达式)。或者,您可以使用描述性编程。
You can change the value of the property in the repository using
SetTOProperty
this changes the value for the current run but not for next runs of the test. Also it changes the value in the stored test object and not in the corresponding control in the application being tested (to get the current value from the application useGetROProperty
there is noSetROProperty
).Note that while you can change the value you can't change whether it's a regular expression (the case above will only work if
5
'stext
property is already defined to use regular expressions).Alternately you can use descriptive programming.