JUnit, Assertion Failed Error

ana-redondo-lopez
ana-redondo-lopez used Ask the Experts™
on
Hi there,

Using Eclipse I'm writing a program to test web pages in Java, with JUnit and HttpUnit.
I'm trying to click on a submit button (button1) inside a table cell. But when I use assert to make sure the button is there I get this message:

pageException in thread "main" junit.framework.AssertionFailedError: expected:<Search for Projects & Documents> but was:<Submit with cmdSearch=Search for Projects & Documents>

The actual value doesn't make any sense to me, what I read from the message is not what  I see in the HTML source of the web page.
I attach both my java code and the HTML source. Please have a look at the line in my java code where I'm creating the variable button1, because the error message comes from the line after that.

Thank you,

Ana  
HTML-PUBLIC.docx
package-secondTrial.doc
Comment
Watch Question

Do more with

Expert Office
EXPERT OFFICE® is a registered trademark of EXPERTS EXCHANGE®
Mick BarryJava Developer
Top Expert 2010

Commented:
you should be comparing the text with the button *value* not the button itself
Java Developer
Top Expert 2010
Commented:
try:

          assertEquals("Search for Projects & Documents", button1.getValue());

Author

Commented:
Great and quick help!

Author

Commented:
Now I'm trying to click on the button and check the retrieved page is the expected one.
But I get this message:
Exception in thread "main" junit.framework.AssertionFailedError: expected:<http://cbrint172/DMS_test_area/search.aspx> but was:<http://cbrint172/DMS_test_area/default.aspx>

It looks like there hastn't been any clicks on the button, because the page being retrieved is the same one I'm at at the moment. Any ideas?

Ana

Do more with

Expert Office
Submit tech questions to Ask the Experts™ at any time to receive solutions, advice, and new ideas from leading industry professionals.

Start 7-Day Free Trial