Accessing DOM when writing unit test

20 views
Skip to first unread message

Ben McCann

unread,
Feb 19, 2014, 7:59:00 PM2/19/14
to mozilla-la...@googlegroups.com
I'm trying to write a unit test to help get a bug fixed where a tab open event is incorrectly firing. The tab events test is currently calling utils.openTab in order to open a new tab. I need to click a link within that tab. Is there a way I can access the DOM from the object returned by utils.openTab in order to click the link?

Thanks,
Ben

Adrian Aichner

unread,
Apr 6, 2014, 4:56:54 AM4/6/14
to mozilla-la...@googlegroups.com

Looks like (according to https://developer.mozilla.org/en-US/docs/XUL/tab#Methods, untested) you should be able to use

tab = utils.openTab(...);
if (tab) {
link = tab.querySelector('a[href*=part/of/the/link]');
if (link) {
link.click();
}
}

See also http://www.w3.org/TR/2011/REC-css3-selectors-20110929/#attribute-substrings.

Does that help?
Adrian
Reply all
Reply to author
Forward
0 new messages