I confirm I had similar problems with css selectors. I didn't discover it deeply though, but used xpath assertion instead which worked as expected.
m. On Tue, Apr 27, 2010 at 11:04 PM, Núria <nuq...@gmail.com> wrote: > I'm afraid this is a bug. CSS selectors are converted to XPath queries > before the evaluation, and apparently there is something wrong with that > conversion. > > In this case, the expression: > > #person_acti...@checked="checked"] > > is transformed to the XPath query: > > //*...@id='person_active'][checked="checked"] > > The problem here is that the @ before the attribute checked is missing, > therefore it fails to match any element. > > This workaround will get the job done (although it's not a valid selector): > > $this->assertQuery('#person_acti...@checked="checked"]'); > > or you can use the assertXpath() method instead. > > -- > > Núria > > 2010/4/27 David Mintz <da...@davidmintz.org> >> >> I am having some trouble figuring out the magic words. My response body >> contains this: >> >> <input type="checkbox" name="person[active]" id="person_active" value="1" >> checked="checked" /> >> >> In the controller test, I when I say >> >> $this->assertQuery('#person_active'); >> >> the assertion succeeds, but >> >> $this->assertQuery('#person_active[checked="checked"]'); >> >> fails with 'Failed asserting node DENOTED BY >> #person_active[checked="checked"] EXISTS.' >> >> After diddling around with several variations, the only thing that works >> for me is to assert that the containing element contains a checkbox whose >> "checked" attribute is "checked:" >> >> $this->assertQuery('#person_active-element input[checked="checked"]') ; >> >> It might be worth noting that the jQuery snippet >> >> $('#person_active[checked="checked"]').length == 1 >> >> typed into the Firebug console evaluates to true. So it looks like my CSS >> is kosher. >> >> Any ideas? Thanks. >> >> -- >> Support real health care reform: >> http://phimg.org/ >> >> -- >> David Mintz >> http://davidmintz.org/ >> >> > >