Closed Melindrea closed 11 years ago
The node path is (in nearly all cases) much more explicit/verbose than the actual selector used to grab that node.
This is because a very general selector like .comment-block h3.username
could potentially return loads of different nodes throughout a document, and you wouldn't necessarily be able to know which one had the problem. So the node path tries to pin down exactly which node it is that caused the problem - the idea being that you can load up the page in the browser, do a document.querySelectorAll on the nodePath that was returned, and see the problematic node in the inspector.
I say tries, because there's actually a bug with the node path that is causing :nth-child
indices to erroneously count text nodes as well as HTML element nodes, meaning that the node paths are incorrect. You can see issue #9 for more information on this - but I'm just about to push a fix that I'm pretty sure corrects it, as well as a test suite for all the util functions. :)
If you're interested, you can see how the node path determiner works here: https://github.com/cgiffard/Behaviour-Assertion-Sheets/blob/master/lib/helpers.js#L32
In regards to excluding certain paths - the Bas CLI currently doesn't provide much control over the crawl settings. While the crawler it uses, node-simplecrawler can easily offer this level of granularity in its crawl pattern, it is very hard to expose that to the command line without making it really, really confusing!
My recommendation would be to specify the pages that tests apply to in the bas sheet itself. If you're using an @all
condition block, perhaps switch to a @page
condition block and exclude the /wp-admin directories similar to this:
@page (content-type =~ /^text\/html/i) (url !=~ /^\/wp-admin/i) {
... your assertions here ...
}
Remember that conditions for a given block can be stacked indefinitely, and are exclusive (AND) rather than inclusive (OR). So the above example will only select pages which have a content-type beginning with text/html
and that do not have a URL beginning with wp-admin. :)
Hopefully that helps. Please don't hesitate to let me know if you get stuck!
(I'll close this issue as soon as I've pushed the node-path fix.)
So the node-path fix is now in place! Should work for you now. :)
Let me know how you go.
Hey! Just wanted to check whether this change made it easier for you, or whether you still have queries. :)
The way to exclude things worked very well, though still finetuning that one on my side. I haven't had a chance to experiment with it further since I looked over this, but it's a very good start =)
First a query: How does the node path get picked? My test case had a failing test image with the class "no-alt", figuring that would help narrow it down some, but it returned a whole bunch of :nth-child rather than the class.
Second: Is there a way to exclude broader categories, such as anything under the folders wp-admin or wp-content?