开发者

Why do Selenium Python tests look so weird?

I've u开发者_StackOverflowsed the Selenium IDE to generate some test code for my application. The generated Python code for an assertion looks like this.

    try: self.failUnless(sel.is_text_present("Path"))
    except AssertionError, e: self.verificationErrors.append(str(e))

Instead of failing fast, the error is added to a list, and the script continues.

I was wondering what the rationale for this is? Isn't it better to fail fast? Or would this leave the page in an inconsistent state?


This is the difference between a verify and an assert in Selenium. When using verify any failures will be logged but the test will continue, they are in effect a 'soft assertion'. If you want to stop executing your test on a failure try using assert instead.

//verifyTextPresent
try: self.failUnless(sel.is_text_present("My Text"))
except AssertionError, e: self.verificationErrors.append(str(e))

//assertTextPresent
self.failUnless(sel.is_text_present("My Text"))
0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜