After various tries, I must admit my failure.

Here is the Ajax response that I want to test against:

<?xml version="1.0" encoding="UTF-8"?><ajax-response>
<component id="galleryParent" ><![CDATA[<span wicket:id="galleryParent"
id="galleryParent">
            <span wicket:id="gallery" id="handGallery"><wicket:panel>

                        <div wicket:id="thumbsPlaceholder"
id="thumbsPlaceholder29">
                            <div wicket:id="thumbs" id="movers-row">
                                <div wicket:id="crossLinkDiv"
id="cross-link-div5"><a wicket:id="crossLink" class="cross-link"
id="cross-link5" href="#6"><img wicket:id="thumbPlaceholder"
class="nav-thumb" id="placeholder94257429_171b_4d45_91b1_efb201e7045e_img"
src="1.jpg"></img></a></div>
                            </div><div wicket:id="thumbs" id="movers-row">
                                <div wicket:id="crossLinkDiv"
id="cross-link-div6"><a wicket:id="crossLink" class="cross-link"
id="cross-link6" href="#7"><img wicket:id="thumbPlaceholder"
class="nav-thumb" id="placeholderb6681b9c_e58f_41ff_8b33_f9c0134fadb5_img"
src="cards/MountainThumb.jpg"></img></a></div>
                            </div>
                        </div>
                    </div>
                </div>
                </span>
            </span>

</wicket:panel></span>
        </span>]]></component>
</ajax-response>

I've stripped down irrelevant parts. But see the 2 <img> tags with class
"nav-thumb"?.

Now, Here is my test code:

final List<TagTester> tagTester =
TagTester.createTagsByAttribute(HomePageTest.tester.getLastResponseAsString(),
"class", "nav-thumb", false);
Assert.assertNotNull(tagTester);
Assert.assertEquals(7, tagTester.size());

It fails with:

java.lang.AssertionError: expected:<2> but was:<0>

What I think is that since I add my component <span wicket:id="gallery"
id="handGallery"> to my AjaxRequestTarget not directly with add() but using
its parent, then the TagTester can't find it. Just a wild guess, though.

To explain a bit more what I mean: since my component to update via Ajax is
complicated (ListViews and other stuff), I do it like that:

parent.addOrRemove(new Gallery(gallery"));
target.add(parent);

AFAIK this is idiomatic Wicket, but in my case it looks like this is what
has me stuck. Maybe I'm wrong here but if anybody knew a way to retrieve my
two <img> tags with class "nav-thumb" in an Ajax update, that would be
great.

Thanks in advance,

Pierre


On Thu, Jan 31, 2013 at 5:12 PM, Pierre Goupil <goupilpie...@gmail.com>wrote:

> !!!
>
> It looks like I made a mistake: getLastResponseAsString do give the last
> Ajax response. I thought you were speaking about
> getLastResponse().getDocument() which doesn't take Ajax into account.
>
> Thanks, I'll look for that!
>
> Regards,
>
> Pierre
>
>
> On Thu, Jan 31, 2013 at 4:44 PM, Pierre Goupil <goupilpie...@gmail.com>wrote:
>
>> Yes, I could but in fact it returns the last non-Ajax response. I see it
>> when providing it to TagTester#createTagsByAttribute.
>>
>> Thank you anyway.
>>
>>
>> On Thu, Jan 31, 2013 at 4:38 PM, Andrea Del Bene <an.delb...@gmail.com>wrote:
>>
>>> Hi,
>>>
>>> I haven't tested it but I think you could get the last response from
>>> WicketTester (with getLastResponse or getLastResponseAsString), then you
>>> should be able to search your attributes inside the response.
>>>
>>>  Good afternoon,
>>>>
>>>> I'd like to test an Ajax response. More precisely, I'd like to get the
>>>> list
>>>> of HTML tags which attributes have a given value.
>>>>
>>>> I know of TagTester#**createTagsByAttribute but it looks like it is for
>>>> non-Ajax only, correct me if I'm wrong.
>>>>
>>>> Is there any way to do that in a Wicket 6 unit test?
>>>>
>>>> Thanks and regards,
>>>>
>>>> Pierre
>>>>
>>>>
>>>>
>>>>
>>>
>>> ------------------------------**------------------------------**
>>> ---------
>>> To unsubscribe, e-mail: 
>>> users-unsubscribe@wicket.**apache.org<users-unsubscr...@wicket.apache.org>
>>> For additional commands, e-mail: users-h...@wicket.apache.org
>>>
>>>
>>
>>
>> --
>> "Parce que c'est la nuit qu'il est beau de croire à la lumière."
>>
>> Edmond Rostand
>>
>
>
>
> --
> "Parce que c'est la nuit qu'il est beau de croire à la lumière."
>
> Edmond Rostand
>



-- 
"Parce que c'est la nuit qu'il est beau de croire à la lumière."

Edmond Rostand

Reply via email to