Wednesday, January 26, 2011

Xpath checking the amount of text input fields

Programmer Question

Hello everyone,



I am trying to write a phpUnit test in the Zend framework. And this time I for the fun want to test that I have two input fields of type text in my contact form.



So I wrote this line of code:



 $this->assertQueryCount('form#contact-form/input[@type="text"]',2);


But it returns:




1) IndexControllerTest::testCanDisplayContactForm
Failed asserting node DENOTED BY form#contact-form/input[type="text"] OCCURS EXACTLY 2 times




So I have a form with the id 'contact' form. And within this I want to get all the input fields of type text



Any idea's or tips?



Find the answer here

No comments:

Post a Comment

LinkWithin

Related Posts with Thumbnails