RFC: analyze() function?

9 views
Skip to first unread message

Darren Cook

unread,
Apr 1, 2015, 6:02:42 AM4/1/15
to casp...@googlegroups.com
I think the most common casper question, here and on StackOverflow, is
"why isn't XXX found?" Even for those not asking the question, it is
surely the biggest time-waster when developing casper scripts.

I am wondering about an `analyze()` function that would take a selector,
and give some troubleshooting information about it.

* See if it exists. If so, print out all its attributes.

* If it does not exist, try and find something close.
E.g. if the selector has a space, then chop off that last part, and
try again.
E.g. if it has a [...] then try removing that.
E.g. if it starts with "." try with "#" instead, and vice versa.
E.g. your suggestions?

If the removal finds a lot of elements (e.g. 10+) then perhaps set it to
just return the first 3 and last 3?

There is a lot of potential for this to be clever, if I can get a few
quality programmers to contribute.

E.g. starting with: 'input[name="its_there_honest"]'
If that gets shortened to 'input' would it give me information overload?
My ideal return message would instead be:

input[name="its_there_honest"] was not found, but these names exist:
surname
forename
it_is_there_honest
this
that

A levenstein distance algorithm, could take this even further!

How about if it did its analysis, then slept half a second, did it
again, and reported if anything had changed? Timing issue found!

Any thoughts or suggestions? Suggestions that come with code to
implement them go to top of the pile ;-)

Thanks,
Darren

Reply all
Reply to author
Forward
0 new messages