[JWebUnit-users] Re : assertCheckboxPresent works but checkCheckbox fails
Brought to you by:
henryju
From: Julien H. <he...@ya...> - 2011-01-06 08:28:33
|
Hi Gible, Thanks for the feedback, there is probably something to improve here in order to have a more consistent behavior. Please note that checkCheckbox will internally call assertCheckboxPresent so you can simplify your code by removing your call. [1] When there a re several forms in your page it's always a good thing to say on which one you are working, especially when identifying elements by name (as it is allowed to have duplicate name across forms in HTML). Regards, Julien [1] http://jwebunit.sourceforge.net/xref/net/sourceforge/jwebunit/junit/WebTester.html#2355 > >De : Gible Fog <gi...@gi...> >À : jwe...@li... >Envoyé le : Mer 5 janvier 2011, 23h 10min 59s >Objet : [JWebUnit-users] assertCheckboxPresent works but checkCheckbox fails > >This is just a note for others head-butting the same problem. > > >I have the following code in my test: > tester.assertCheckboxPresent("aname", "avalue"); > tester.checkCheckbox("aname", "avalue"); >The (first line) assertion works fine, but the second fails with the result: >"caused an ERROR: No checkbox with name [aname] and value [avalue] was found in >the current form." >The issue is that assertCheckboxPresent >uses getTestingEngine().hasElementByXPath(..) to determine success whereas the >second iterates through the named input elements of the current form checking >each for type and value. This fails for me because I'm actually interested in >the /not first/ form of the page and unles you select a form first >with setWorkingForm(...) it only searchs the first form on the page. > > >My solution: > tester.setWorkingForm("aform"); > tester.assertCheckboxPresent("aname", "avalue"); > tester.checkCheckbox("aname", "avalue"); > > > > >regards >Gible |