Selenium:将正则表达式与 getLocation 一起使用
我以前使用过 Selenium RC,下面的语句工作得很好:
verifyEquals("*/en-us/", selenium.getLocation());
现在我使用 Hudson、Ant 和 SeleniumRC,但这个语句不起作用。我收到一条消息:
org.junit.comparisonFailure:预期:“*/en-us/”,但实际是 “http://www.testwebsite.com/en-us/”。
它似乎没有将 "*/en-us/"
视为正则表达式。
I was using Selenium RC some time back and the statement below worked fine:
verifyEquals("*/en-us/", selenium.getLocation());
Now I am using Hudson, Ant and SeleniumRC and this statement does not work. I am getting a message:
org.junit.comparisonFailure: expected:"*/en-us/" but was
"http://www.testwebsite.com/en-us/".
It does not seem to consider "*/en-us/"
as a regular expression.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
我在此 博客
verifyEquals("*/en-us/", selenium.getLocation());
是一个全局模式,应该没问题(这就是你所拥有的,但由于某种原因不起作用)
verifyEquals("regexp:^.*/en-us/ $", selenium.getLocation());
是一个正则表达式模式,应该做同样的事情。
再次检查全局模式解决方案是否有拼写错误,或尝试一下正则表达式解决方案。
希望这会有所帮助。
更新
(现在有点猜测......发现了一些(不)相关的此处)
尝试
seleniumEquals
插入verifyEquals
I found some info in this blog
verifyEquals("*/en-us/", selenium.getLocation());
is a global pattern and should be fine (well this is what you have and for some reason doesn't work)
verifyEquals("regexp:^.*/en-us/$", selenium.getLocation());
is a regular expression pattern that should do the same.
check the global pattern solution once more for typos or give the regular expression solution a try.
hope this will help.
update
(it's kind of guessing now... found something (un)related here)
try
seleniumEquals
insted ofverifyEquals