Hi,

Generally it's better to not have these sorts of if/else blocks in test
cases. If you are testing a whole lot of generated pages, then I think it's
better to write test cases for the generation code.

In JUnit all test case methods assertXXX() should throw an
AssertionFailedError if the test fails (see TestCase.fail()) so you can
catch this if necessary.

If you are just looking to see if an element exists, look at the
getElement() methods.

Hope this helps!
Jevon

On Fri, Jul 24, 2009 at 8:30 AM, Stand Trooper <standtroo...@gmail.com>wrote:

> Ok, so I've been toying with this for a day or so without revelation, so
> I'm hoping that I can find the answer here.  I've searched the cryptic
> archives and read javadocs and even played with a lot of different things.
>
> What I need to do is find out if an element is present before I move on.
>
> for example:
> if (elementExists("//d...@id='bob']")) {
> //perform action
> }
>
> or even an override to getElement that passes a boolean to not do the
> assertion, if the element doesn't exist it returns a null object.
>
> Right now, I have a series of interactions on forms that may cause errors
> that I'm testing, if an error displays, then an element will show up on the
> page.  I'm doing about 295,000 automated tests right now and I'll be bumping
> that up to about 895k tests once these are done.  I can't just do an
> assertTextPresent or assertTextNotPresent, I need to detect if something is
> there, if it is, then perform a specific action and move on without taking
> down the tests and having to start over.
>
> Is there anything like that that I can use?  If not, that's ok, I'll have
> to write some code, unless someone has something quick in mind.
>
> thx
>
> timo
> StandTrooper
>
>
> ------------------------------------------------------------------------------
>
> _______________________________________________
> JWebUnit-users mailing list
> JWebUnit-users@lists.sourceforge.net
> https://lists.sourceforge.net/lists/listinfo/jwebunit-users
>
>
------------------------------------------------------------------------------
_______________________________________________
JWebUnit-users mailing list
JWebUnit-users@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/jwebunit-users

Reply via email to