Closed Bug 617427 Opened 15 years ago Closed 15 years ago

add Selector option to elementslib to get elements by CSS selector

Categories

(Testing Graveyard :: Mozmill, defect)

defect
Not set
normal

Tracking

(Not tracked)

VERIFIED FIXED

People

(Reporter: harth, Assigned: harth)

Details

(Whiteboard: [mozmill-doc-needed][mozmill-1.5.2+])

Attachments

(1 file)

I personally find CSS selectors much easier to use than XPath queries for e.g. getting an element with a class name. We should add a Selector API to the elementslib as an option for fetching elements that works like: var tab = new elementslib.Selector(controller.window.document, ".tab"); var tab1 = tab.getNode(); var tab4 = tab.getNode(3); // get the fourth node that matches the selector
Assignee: nobody → fayearthur+bugs
Please also check the implementation we have in nodeCollector: http://hg.mozilla.org/qa/mozmill-tests/file/default/shared-modules/dom-utils.js#l487 It's a bit different but also covers filtering of properties and anonymous nodes.
(In reply to comment #2) > Please also check the implementation we have in nodeCollector: > > http://hg.mozilla.org/qa/mozmill-tests/file/default/shared-modules/dom-utils.js#l487 > > It's a bit different but also covers filtering of properties and anonymous > nodes. This is good stuff, but I don't think it needs to be in the Selector API, I'd rather it just be a simple proxy for querySelectorAll() and mirror CSS selectors. The XPath option can handle anon elements. We could work in the future on a better, unified way of fetching elements, but I think we should get this in for right now.
Attachment #495939 - Flags: review?(ctalbert)
(In reply to comment #3) > We could work in the future on a better, unified way of fetching elements, but > I think we should get this in for right now. Yes, that's why the nodeCollector has been created and will be further improved. It was just another info as we have talked during this weeks meeting.
Comment on attachment 495939 [details] [diff] [review] add elementslib.Selector() This looks good. Can I get a test with this patch? Then you'll be good to go. r+ with test.
Attachment #495939 - Flags: review?(ctalbert) → review+
Verified fixed for chrome and content elements. We also have to document this feature on MDN.
Status: RESOLVED → VERIFIED
Whiteboard: [mozmill-doc-needed][mozmill-1.5.2+]
Heather, can we please get this feature documented? It's kinda important for us now. https://developer.mozilla.org/en/Mozmill/Mozmill_Elements_Library_Object
Flags: in-testsuite?
Flags: in-testsuite? → in-testsuite+
Ping Heather. Would be nice to get this documented. People want to use this method but don't have any documentation available. Thanks.
Product: Testing → Testing Graveyard
You need to log in before you can comment on or make changes to this bug.

Attachment

General

Created:
Updated:
Size: