Closed sjieg closed 9 years ago
Try adding :message
to the hash. I'm not 100% sure it will work as expected, but there's a mechanism in there already for passing messages through.
Either way, I completely agree with the feature request.
You probably found out yourself by now that :message
doesn't work quite like that, and that's because find overwrites it.
I'll figure out how to best add this feature and will let you know.
Made :message
work like that. It was the cleanest solution.
The error
function is quite complex; adding yet another parameter to it makes things worse. The change is in find
, which no longer sets :message
everywhere, but only does so if no :message
was passed yet.
In the log, it'll look like this:
browser.find(:a => {:title => 'notfound'}, :message => "foo")
E, [2015-02-13T17:26:04.580192 #13702] ERROR -- #<IO:0x00000001e54290>: foo - Cannot find elements with selectors: {:pick=>:first, :mode=>:match_one, :message=>"foo", :selectors=>[{:a=>{:title=>"notfound"}}]} (http://www.spritecloud.com/)
That'll give you all the power for making error messages more consumer-friendly, whilst leaving everything in that you might need for debugging.
The default message given by .find/.wait are fine for the TA developers, but when these messages are eventually shown to the customer you want a more user friendly message.
Because of this we will have to do a lot of try/catch in the step definitions. Adding the possibility to override the default error message will prevent this.
Because this would be a user friendly message, while debugging this would not be useful. So when enabling debug mode I'd expect to see both the custom message and the default produced error by LL.