/** * Accessor for a form element value within the page. * @param string/integer $id Id of field in forms. * @return string/boolean A string if the field is * present, false if unchecked * and null if missing. * @access public */ function getFieldById($id) { return $this->page->getField(new SimpleById($id)); }
function testInputFieldCanBeReadBackByLabel() { $label = new SimpleLabelTag(array()); $page = new SimplePage(new MockSimpleHttpResponse()); $page->acceptFormStart(new SimpleFormTag(array("method" => "GET", "action" => "here.php"))); $page->acceptLabelStart($label); $label->addContent('l'); $page->AcceptTag(new SimpleTextTag(array("type" => "text", "name" => "a", "value" => "A"))); $page->acceptLabelEnd(); $page->AcceptTag(new SimpleSubmitTag(array("type" => "submit", "name" => "s"))); $page->acceptFormEnd(); $this->assertEqual($page->getField(new SimpleByLabel('l')), 'A'); }