diff options
author | wei <> | 2006-07-07 23:18:19 +0000 |
---|---|---|
committer | wei <> | 2006-07-07 23:18:19 +0000 |
commit | b2e97539e7af7712b04dd5c2610a454d09aa0333 (patch) | |
tree | d09ae76ddc7f349a39b74b0cb1f40c8b678a352e /tests/test_tools/simpletest/browser.php | |
parent | fce10eed76455b7e0419f13affb4f29e73ef0375 (diff) |
Update simpletest
Diffstat (limited to 'tests/test_tools/simpletest/browser.php')
-rw-r--r-- | tests/test_tools/simpletest/browser.php | 397 |
1 files changed, 219 insertions, 178 deletions
diff --git a/tests/test_tools/simpletest/browser.php b/tests/test_tools/simpletest/browser.php index 06e1b8d7..8e843b18 100644 --- a/tests/test_tools/simpletest/browser.php +++ b/tests/test_tools/simpletest/browser.php @@ -3,22 +3,25 @@ * Base include file for SimpleTest * @package SimpleTest * @subpackage WebTester - * @version $Id: browser.php,v 1.141 2005/02/22 02:39:21 lastcraft Exp $ + * @version $Id: browser.php,v 1.162 2006/02/05 01:07:49 lastcraft Exp $ */ - + /**#@+ * include other SimpleTest class files */ - require_once(dirname(__FILE__) . '/options.php'); + require_once(dirname(__FILE__) . '/simpletest.php'); require_once(dirname(__FILE__) . '/http.php'); require_once(dirname(__FILE__) . '/encoding.php'); require_once(dirname(__FILE__) . '/page.php'); + require_once(dirname(__FILE__) . '/selector.php'); require_once(dirname(__FILE__) . '/frames.php'); require_once(dirname(__FILE__) . '/user_agent.php'); /**#@-*/ - - define('DEFAULT_MAX_NESTED_FRAMES', 3); - + + if (!defined('DEFAULT_MAX_NESTED_FRAMES')) { + define('DEFAULT_MAX_NESTED_FRAMES', 3); + } + /** * Browser history list. * @package SimpleTest @@ -27,7 +30,7 @@ class SimpleBrowserHistory { protected $_sequence; protected $_position; - + /** * Starts empty. * @access public @@ -36,7 +39,7 @@ $this->_sequence = array(); $this->_position = -1; } - + /** * Test for no entries yet. * @return boolean True if empty. @@ -45,7 +48,7 @@ function _isEmpty() { return ($this->_position == -1); } - + /** * Test for being at the beginning. * @return boolean True if first. @@ -54,7 +57,7 @@ function _atBeginning() { return ($this->_position == 0) && ! $this->_isEmpty(); } - + /** * Test for being at the last entry. * @return boolean True if last. @@ -63,36 +66,21 @@ function _atEnd() { return ($this->_position + 1 >= count($this->_sequence)) && ! $this->_isEmpty(); } - + /** * Adds a successfully fetched page to the history. - * @param string $method GET or POST. * @param SimpleUrl $url URL of fetch. - * @param SimpleFormEncoding $parameters Any post data with the fetch. + * @param SimpleEncoding $parameters Any post data with the fetch. * @access public */ - function recordEntry($method, $url, $parameters) { + function recordEntry($url, $parameters) { $this->_dropFuture(); array_push( $this->_sequence, - array('method' => $method, 'url' => $url, 'parameters' => $parameters)); + array('url' => $url, 'parameters' => $parameters)); $this->_position++; } - - /** - * Last fetching method for current history - * position. - * @return string GET or POST for this point in - * the history. - * @access public - */ - function getMethod() { - if ($this->_isEmpty()) { - return false; - } - return $this->_sequence[$this->_position]['method']; - } - + /** * Last fully qualified URL for current history * position. @@ -105,7 +93,7 @@ } return $this->_sequence[$this->_position]['url']; } - + /** * Parameters of last fetch from current history * position. @@ -118,7 +106,7 @@ } return $this->_sequence[$this->_position]['parameters']; } - + /** * Step back one place in the history. Stops at * the first page. @@ -132,7 +120,7 @@ $this->_position--; return true; } - + /** * Step forward one place. If already at the * latest entry then nothing will happen. @@ -146,7 +134,7 @@ $this->_position++; return true; } - + /** * Ditches all future entries beyond the current * point. @@ -161,7 +149,7 @@ } } } - + /** * Simulated web browser. This is an aggregate of * the user agent, the HTML parsing, request history @@ -175,7 +163,7 @@ protected $_history; protected $_ignore_frames; protected $_maximum_nested_frames; - + /** * Starts with a fresh browser with no * cookie or any other state information. The @@ -186,33 +174,35 @@ function SimpleBrowser() { $this->_user_agent = $this->_createUserAgent(); $this->_user_agent->useProxy( - SimpleTestOptions::getDefaultProxy(), - SimpleTestOptions::getDefaultProxyUsername(), - SimpleTestOptions::getDefaultProxyPassword()); + SimpleTest::getDefaultProxy(), + SimpleTest::getDefaultProxyUsername(), + SimpleTest::getDefaultProxyPassword()); $this->_page = new SimplePage(); $this->_history = $this->_createHistory(); $this->_ignore_frames = false; $this->_maximum_nested_frames = DEFAULT_MAX_NESTED_FRAMES; } - + /** * Creates the underlying user agent. * @return SimpleFetcher Content fetcher. * @access protected */ - function _createUserAgent() { - return new SimpleUserAgent(); + function &_createUserAgent() { + $user_agent = new SimpleUserAgent(); + return $user_agent; } - + /** * Creates a new empty history list. * @return SimpleBrowserHistory New list. * @access protected */ - function _createHistory() { - return new SimpleBrowserHistory(); + function &_createHistory() { + $history = new SimpleBrowserHistory(); + return $history; } - + /** * Disables frames support. Frames will not be fetched * and the frameset page will be used instead. @@ -221,7 +211,7 @@ function ignoreFrames() { $this->_ignore_frames = true; } - + /** * Enables frames support. Frames will be fetched from * now on. @@ -232,93 +222,122 @@ } /** + * Switches off cookie sending and recieving. + * @access public + */ + function ignoreCookies() { + $this->_user_agent->ignoreCookies(); + } + + /** + * Switches back on the cookie sending and recieving. + * @access public + */ + function useCookies() { + $this->_user_agent->useCookies(); + } + + /** * Parses the raw content into a page. Will load further * frame pages unless frames are disabled. * @param SimpleHttpResponse $response Response from fetch. * @param integer $depth Nested frameset depth. * @return SimplePage Parsed HTML. - * @access protected + * @access private */ - function _parse($response, $depth = 0) { - $builder = new SimplePageBuilder(); - $page = $builder->parse($response); + function &_parse($response, $depth = 0) { + $page = $this->_buildPage($response); if ($this->_ignore_frames || ! $page->hasFrames() || ($depth > $this->_maximum_nested_frames)) { return $page; } $frameset = new SimpleFrameset($page); foreach ($page->getFrameset() as $key => $url) { - $frame = $this->_fetch('GET', $url, array(), $depth + 1); + $frame = $this->_fetch($url, new SimpleGetEncoding(), $depth + 1); $frameset->addFrame($frame, $key); } return $frameset; } /** - * Fetches a page. - * @param string $method GET or POST. - * @param string/SimpleUrl $url Target to fetch as string. - * @param SimpleFormEncoding $parameters POST parameters. - * @param integer $depth Nested frameset depth protection. - * @return SimplePage Parsed page. + * Assembles the parsing machinery and actually parses + * a single page. Frees all of the builder memory and so + * unjams the PHP memory management. + * @param SimpleHttpResponse $response Response from fetch. + * @return SimplePage Parsed top level page. + * @access protected + */ + function &_buildPage($response) { + $builder = new SimplePageBuilder(); + $page = $builder->parse($response); + $builder->free(); + unset($builder); + return $page; + } + + /** + * Fetches a page. Jointly recursive with the _parse() + * method as it descends a frameset. + * @param string/SimpleUrl $url Target to fetch. + * @param SimpleEncoding $encoding GET/POST parameters. + * @param integer $depth Nested frameset depth protection. + * @return SimplePage Parsed page. * @access private */ - function _fetch($method, $url, $parameters, $depth = 0) { - $response = $this->_user_agent->fetchResponse($method, $url, $parameters); + function &_fetch($url, $encoding, $depth = 0) { + $response = $this->_user_agent->fetchResponse($url, $encoding); if ($response->isError()) { - return new SimplePage($response); + $page = new SimplePage($response); + } else { + $page = $this->_parse($response, $depth); } - return $this->_parse($response, $depth); + return $page; } - + /** * Fetches a page or a single frame if that is the current * focus. - * @param string $method GET or POST. - * @param string/SimpleUrl $url Target to fetch as string. - * @param SimpleFormEncoding $parameters POST parameters. + * @param SimpleUrl $url Target to fetch. + * @param SimpleEncoding $parameters GET/POST parameters. * @return string Raw content of page. * @access private */ - function _load($method, $url, $parameters = false) { + function _load($url, $parameters) { $frame = $url->getTarget(); if (! $frame || ! $this->_page->hasFrames() || (strtolower($frame) == '_top')) { - return $this->_loadPage($method, $url, $parameters); + return $this->_loadPage($url, $parameters); } - return $this->_loadFrame(array($frame), $method, $url, $parameters); + return $this->_loadFrame(array($frame), $url, $parameters); } - + /** * Fetches a page and makes it the current page/frame. - * @param string $method GET or POST. * @param string/SimpleUrl $url Target to fetch as string. - * @param SimpleFormEncoding $parameters POST parameters. + * @param SimplePostEncoding $parameters POST parameters. * @return string Raw content of page. * @access private */ - function _loadPage($method, $url, $parameters = false) { - $this->_page = $this->_fetch(strtoupper($method), $url, $parameters); + function _loadPage($url, $parameters) { + $this->_page = $this->_fetch($url, $parameters); $this->_history->recordEntry( - $this->_page->getMethod(), $this->_page->getUrl(), $this->_page->getRequestData()); return $this->_page->getRaw(); } - + /** * Fetches a frame into the existing frameset replacing the * original. * @param array $frames List of names to drill down. - * @param string $method GET or POST. * @param string/SimpleUrl $url Target to fetch as string. * @param SimpleFormEncoding $parameters POST parameters. * @return string Raw content of page. * @access private */ - function _loadFrame($frames, $method, $url, $parameters = false) { - $page = $this->_fetch(strtoupper($method), $url, $parameters); + function _loadFrame($frames, $url, $parameters) { + $page = $this->_fetch($url, $parameters); $this->_page->setFrame($frames, $page); } - + /** * Removes expired and temporary cookies as if * the browser was closed and re-opened. @@ -330,7 +349,7 @@ function restart($date = false) { $this->_user_agent->restart($date); } - + /** * Adds a header to every fetch. * @param string $header Header line to add to every @@ -340,7 +359,7 @@ function addHeader($header) { $this->_user_agent->addHeader($header); } - + /** * Ages the cookies by the specified time. * @param integer $interval Amount in seconds. @@ -349,7 +368,7 @@ function ageCookies($interval) { $this->_user_agent->ageCookies($interval); } - + /** * Sets an additional cookie. If a cookie has * the same name and path it is replaced. @@ -363,7 +382,7 @@ function setCookie($name, $value, $host = false, $path = '/', $expiry = false) { $this->_user_agent->setCookie($name, $value, $host, $path, $expiry); } - + /** * Reads the most specific cookie value from the * browser cookies. @@ -377,7 +396,7 @@ function getCookieValue($host, $path, $name) { return $this->_user_agent->getCookieValue($host, $path, $name); } - + /** * Reads the current cookies for the current URL. * @param string $name Key of cookie to find. @@ -388,7 +407,7 @@ function getCurrentCookieValue($name) { return $this->_user_agent->getBaseCookieValue($name, $this->_page->getUrl()); } - + /** * Sets the maximum number of redirects before * a page will be loaded anyway. @@ -398,7 +417,7 @@ function setMaximumRedirects($max) { $this->_user_agent->setMaximumRedirects($max); } - + /** * Sets the maximum number of nesting of framed pages * within a framed page to prevent loops. @@ -408,7 +427,7 @@ function setMaximumNestedFrames($max) { $this->_maximum_nested_frames = $max; } - + /** * Sets the socket timeout for opening a connection. * @param integer $timeout Maximum time in seconds. @@ -417,7 +436,7 @@ function setConnectionTimeout($timeout) { $this->_user_agent->setConnectionTimeout($timeout); } - + /** * Sets proxy to use on all requests for when * testing from behind a firewall. Set URL @@ -430,12 +449,12 @@ function useProxy($proxy, $username = false, $password = false) { $this->_user_agent->useProxy($proxy, $username, $password); } - + /** * Fetches the page content with a HEAD request. * Will affect cookies, but will not change the base URL. * @param string/SimpleUrl $url Target to fetch as string. - * @param hash/SimpleFormEncoding $parameters Additional parameters for + * @param hash/SimpleHeadEncoding $parameters Additional parameters for * HEAD request. * @return boolean True if successful. * @access public @@ -444,19 +463,13 @@ if (! is_object($url)) { $url = new SimpleUrl($url); } - if (is_array($parameters)) { - $parameters = new SimpleFormEncoding($parameters); - } if ($this->getUrl()) { $url = $url->makeAbsolute($this->getUrl()); } - $response = $this->_user_agent->fetchResponse( - 'HEAD', - $url, - $parameters); + $response = $this->_user_agent->fetchResponse($url, new SimpleHeadEncoding($parameters)); return ! $response->isError(); } - + /** * Fetches the page content with a simple GET request. * @param string/SimpleUrl $url Target to fetch. @@ -469,15 +482,12 @@ if (! is_object($url)) { $url = new SimpleUrl($url); } - if (is_array($parameters)) { - $parameters = new SimpleFormEncoding($parameters); - } if ($this->getUrl()) { $url = $url->makeAbsolute($this->getUrl()); } - return $this->_load('GET', $url, $parameters); + return $this->_load($url, new SimpleGetEncoding($parameters)); } - + /** * Fetches the page content with a POST request. * @param string/SimpleUrl $url Target to fetch as string. @@ -489,15 +499,12 @@ if (! is_object($url)) { $url = new SimpleUrl($url); } - if (is_array($parameters)) { - $parameters = new SimpleFormEncoding($parameters); - } if ($this->getUrl()) { $url = $url->makeAbsolute($this->getUrl()); } - return $this->_load('POST', $url, $parameters); + return $this->_load($url, new SimplePostEncoding($parameters)); } - + /** * Equivalent to hitting the retry button on the * browser. Will attempt to repeat the page fetch. If @@ -511,25 +518,22 @@ if (count($frames) > 0) { $this->_loadFrame( $frames, - $this->_page->getMethod(), $this->_page->getUrl(), $this->_page->getRequestData()); return $this->_page->getRaw(); } - if ($method = $this->_history->getMethod()) { - $this->_page = $this->_fetch( - $method, - $this->_history->getUrl(), - $this->_history->getParameters()); + if ($url = $this->_history->getUrl()) { + $this->_page = $this->_fetch($url, $this->_history->getParameters()); return $this->_page->getRaw(); } return false; } - + /** * Equivalent to hitting the back button on the * browser. The browser history is unchanged on - * failure. + * failure. The page content is refetched as there + * is no concept of content caching in SimpleTest. * @return boolean True if history entry and * fetch succeeded * @access public @@ -544,11 +548,12 @@ } return $content; } - + /** * Equivalent to hitting the forward button on the * browser. The browser history is unchanged on - * failure. + * failure. The page content is refetched as there + * is no concept of content caching in SimpleTest. * @return boolean True if history entry and * fetch succeeded * @access public @@ -563,7 +568,7 @@ } return $content; } - + /** * Retries a request after setting the authentication * for the current realm. @@ -589,7 +594,7 @@ $password); return $this->retry(); } - + /** * Accessor for a breakdown of the frameset. * @return array Hash tree of frames by name @@ -599,7 +604,7 @@ function getFrames() { return $this->_page->getFrames(); } - + /** * Accessor for current frame focus. Will be * false if no frame has focus. @@ -611,7 +616,7 @@ function getFrameFocus() { return $this->_page->getFrameFocus(); } - + /** * Sets the focus by index. The integer index starts from 1. * @param integer $choice Chosen frame. @@ -621,7 +626,7 @@ function setFrameFocusByIndex($choice) { return $this->_page->setFrameFocusByIndex($choice); } - + /** * Sets the focus by name. * @param string $name Chosen frame. @@ -631,7 +636,7 @@ function setFrameFocus($name) { return $this->_page->setFrameFocus($name); } - + /** * Clears the frame focus. All frames will be searched * for content. @@ -640,7 +645,7 @@ function clearFrameFocus() { return $this->_page->clearFrameFocus(); } - + /** * Accessor for last error. * @return string Error from last response. @@ -649,7 +654,7 @@ function getTransportError() { return $this->_page->getTransportError(); } - + /** * Accessor for current MIME type. * @return string MIME type as string; e.g. 'text/html' @@ -658,7 +663,7 @@ function getMimeType() { return $this->_page->getMimeType(); } - + /** * Accessor for last response code. * @return integer Last HTTP response code received. @@ -667,7 +672,7 @@ function getResponseCode() { return $this->_page->getResponseCode(); } - + /** * Accessor for last Authentication type. Only valid * straight after a challenge (401). @@ -677,7 +682,7 @@ function getAuthentication() { return $this->_page->getAuthentication(); } - + /** * Accessor for last Authentication realm. Only valid * straight after a challenge (401). @@ -687,7 +692,7 @@ function getRealm() { return $this->_page->getRealm(); } - + /** * Accessor for current URL of page or frame if * focused. @@ -698,7 +703,7 @@ $url = $this->_page->getUrl(); return $url ? $url->asString() : false; } - + /** * Accessor for raw bytes sent down the wire. * @return string Original text sent. @@ -725,7 +730,7 @@ function getContent() { return $this->_page->getRaw(); } - + /** * Accessor for plain text version of the page. * @return string Normalised text representation. @@ -734,7 +739,7 @@ function getContentAsText() { return $this->_page->getText(); } - + /** * Accessor for parsed title. * @return string Title or false if no title is present. @@ -743,7 +748,7 @@ function getTitle() { return $this->_page->getTitle(); } - + /** * Accessor for a list of all fixed links in current page. * @return array List of urls with scheme of @@ -753,7 +758,7 @@ function getAbsoluteUrls() { return $this->_page->getAbsoluteUrls(); } - + /** * Accessor for a list of all relative links. * @return array List of urls without hostname. @@ -762,18 +767,30 @@ function getRelativeUrls() { return $this->_page->getRelativeUrls(); } - + /** * Sets all form fields with that name. + * @param string $label Name or label of field in forms. + * @param string $value New value of field. + * @return boolean True if field exists, otherwise false. + * @access public + */ + function setField($label, $value) { + return $this->_page->setField(new SimpleByLabelOrName($label), $value); + } + + /** + * Sets all form fields with that name. Will use label if + * one is available (not yet implemented). * @param string $name Name of field in forms. * @param string $value New value of field. * @return boolean True if field exists, otherwise false. * @access public */ - function setField($name, $value) { - return $this->_page->setField($name, $value); + function setFieldByName($name, $value) { + return $this->_page->setField(new SimpleByName($name), $value); } - + /** * Sets all form fields with that id attribute. * @param string/integer $id Id of field in forms. @@ -782,9 +799,22 @@ * @access public */ function setFieldById($id, $value) { - return $this->_page->setFieldById($id, $value); + return $this->_page->setField(new SimpleById($id), $value); } - + + /** + * Accessor for a form element value within the page. + * Finds the first match. + * @param string $label Field label. + * @return string/boolean A value if the field is + * present, false if unchecked + * and null if missing. + * @access public + */ + function getField($label) { + return $this->_page->getField(new SimpleByLabelOrName($label)); + } + /** * Accessor for a form element value within the page. * Finds the first match. @@ -794,10 +824,10 @@ * and null if missing. * @access public */ - function getField($name) { - return $this->_page->getField($name); + function getFieldByName($name) { + return $this->_page->getField(new SimpleByName($name)); } - + /** * Accessor for a form element value within the page. * @param string/integer $id Id of field in forms. @@ -807,9 +837,9 @@ * @access public */ function getFieldById($id) { - return $this->_page->getFieldById($id); + return $this->_page->getField(new SimpleById($id)); } - + /** * Clicks the submit button by label. The owning * form will be submitted by this. @@ -820,16 +850,15 @@ * @access public */ function clickSubmit($label = 'Submit', $additional = false) { - if (! ($form = $this->_page->getFormBySubmitLabel($label))) { + if (! ($form = $this->_page->getFormBySubmit(new SimpleByLabel($label)))) { return false; } $success = $this->_load( - $form->getMethod(), $form->getAction(), - $form->submitButtonByLabel($label, $additional)); + $form->submitButton(new SimpleByLabel($label), $additional)); return ($success ? $this->getContent() : $success); } - + /** * Clicks the submit button by name attribute. The owning * form will be submitted by this. @@ -839,16 +868,15 @@ * @access public */ function clickSubmitByName($name, $additional = false) { - if (! ($form = $this->_page->getFormBySubmitName($name))) { + if (! ($form = $this->_page->getFormBySubmit(new SimpleByName($name)))) { return false; } $success = $this->_load( - $form->getMethod(), $form->getAction(), - $form->submitButtonByName($name, $additional)); + $form->submitButton(new SimpleByName($name), $additional)); return ($success ? $this->getContent() : $success); } - + /** * Clicks the submit button by ID attribute of the button * itself. The owning form will be submitted by this. @@ -858,16 +886,15 @@ * @access public */ function clickSubmitById($id, $additional = false) { - if (! ($form = $this->_page->getFormBySubmitId($id))) { + if (! ($form = $this->_page->getFormBySubmit(new SimpleById($id)))) { return false; } $success = $this->_load( - $form->getMethod(), $form->getAction(), - $form->submitButtonById($id, $additional)); + $form->submitButton(new SimpleById($id), $additional)); return ($success ? $this->getContent() : $success); } - + /** * Clicks the submit image by some kind of label. Usually * the alt tag or the nearest equivalent. The owning @@ -882,16 +909,15 @@ * @access public */ function clickImage($label, $x = 1, $y = 1, $additional = false) { - if (! ($form = $this->_page->getFormByImageLabel($label))) { + if (! ($form = $this->_page->getFormByImage(new SimpleByLabel($label)))) { return false; } $success = $this->_load( - $form->getMethod(), $form->getAction(), - $form->submitImageByLabel($label, $x, $y, $additional)); + $form->submitImage(new SimpleByLabel($label), $x, $y, $additional)); return ($success ? $this->getContent() : $success); } - + /** * Clicks the submit image by the name. Usually * the alt tag or the nearest equivalent. The owning @@ -906,16 +932,15 @@ * @access public */ function clickImageByName($name, $x = 1, $y = 1, $additional = false) { - if (! ($form = $this->_page->getFormByImageName($name))) { + if (! ($form = $this->_page->getFormByImage(new SimpleByName($name)))) { return false; } $success = $this->_load( - $form->getMethod(), $form->getAction(), - $form->submitImageByName($name, $x, $y, $additional)); + $form->submitImage(new SimpleByName($name), $x, $y, $additional)); return ($success ? $this->getContent() : $success); } - + /** * Clicks the submit image by ID attribute. The owning * form will be submitted by this. Clicking outside of @@ -929,16 +954,15 @@ * @access public */ function clickImageById($id, $x = 1, $y = 1, $additional = false) { - if (! ($form = $this->_page->getFormByImageId($id))) { + if (! ($form = $this->_page->getFormByImage(new SimpleById($id)))) { return false; } $success = $this->_load( - $form->getMethod(), $form->getAction(), - $form->submitImageById($id, $x, $y, $additional)); + $form->submitImage(new SimpleById($id), $x, $y, $additional)); return ($success ? $this->getContent() : $success); } - + /** * Submits a form by the ID. * @param string $id The form ID. No submit button value @@ -951,12 +975,11 @@ return false; } $success = $this->_load( - $form->getMethod(), $form->getAction(), $form->submit()); return ($success ? $this->getContent() : $success); } - + /** * Follows a link by label. Will click the first link * found with this link text by default, or a later @@ -975,10 +998,10 @@ if (count($urls) < $index + 1) { return false; } - $this->_load('GET', $urls[$index]); + $this->_load($urls[$index], new SimpleGetEncoding()); return $this->getContent(); } - + /** * Tests to see if a link is present by label. * @param string $label Text of value attribute. @@ -988,7 +1011,7 @@ function isLink($label) { return (count($this->_page->getUrlsByLabel($label)) > 0); } - + /** * Follows a link by id attribute. * @param string $id ID attribute value. @@ -999,10 +1022,10 @@ if (! ($url = $this->_page->getUrlById($id))) { return false; } - $this->_load('GET', $url); + $this->_load($url, new SimpleGetEncoding()); return $this->getContent(); } - + /** * Tests to see if a link is present by ID attribute. * @param string $id Text of id attribute. @@ -1012,5 +1035,23 @@ function isLinkById($id) { return (boolean)$this->_page->getUrlById($id); } + + /** + * Clicks a visible text item. Will first try buttons, + * then links and then images. + * @param string $label Visible text or alt text. + * @return string/boolean Raw page or false. + * @access public + */ + function click($label) { + $raw = $this->clickSubmit($label); + if (! $raw) { + $raw = $this->clickLink($label); + } + if (! $raw) { + $raw = $this->clickImage($label); + } + return $raw; + } } ?>
\ No newline at end of file |