Complex classes like SimpleBrowser often do a lot of different things. To break such a class down, we need to identify a cohesive component within that class. A common approach to find such a component is to look for fields/methods that share the same prefixes, or suffixes. You can also have a look at the cohesion graph to spot any un-connected, or weakly-connected components.
Once you have determined the fields that belong together, you can apply the Extract Class refactoring. If the component makes sense as a sub-class, Extract Subclass is also a candidate, and is often faster.
While breaking up the class, it is a good idea to analyze how other classes use SimpleBrowser, and based on these observations, apply Extract Interface, too.
| 1 | <?php |
||
| 160 | class SimpleBrowser { |
||
| 161 | protected $_user_agent; |
||
| 162 | protected $_page; |
||
| 163 | protected $_history; |
||
| 164 | protected $_ignore_frames; |
||
| 165 | protected $_maximum_nested_frames; |
||
| 166 | |||
| 167 | /** |
||
| 168 | * Starts with a fresh browser with no |
||
| 169 | * cookie or any other state information. The |
||
| 170 | * exception is that a default proxy will be |
||
| 171 | * set up if specified in the options. |
||
| 172 | * @access public |
||
| 173 | */ |
||
| 174 | function SimpleBrowser() { |
||
| 185 | |||
| 186 | /** |
||
| 187 | * Creates the underlying user agent. |
||
| 188 | * @return SimpleFetcher Content fetcher. |
||
| 189 | * @access protected |
||
| 190 | */ |
||
| 191 | function &_createUserAgent() { |
||
| 195 | |||
| 196 | /** |
||
| 197 | * Creates a new empty history list. |
||
| 198 | * @return SimpleBrowserHistory New list. |
||
| 199 | * @access protected |
||
| 200 | */ |
||
| 201 | function &_createHistory() { |
||
| 205 | |||
| 206 | /** |
||
| 207 | * Disables frames support. Frames will not be fetched |
||
| 208 | * and the frameset page will be used instead. |
||
| 209 | * @access public |
||
| 210 | */ |
||
| 211 | function ignoreFrames() { |
||
| 214 | |||
| 215 | /** |
||
| 216 | * Enables frames support. Frames will be fetched from |
||
| 217 | * now on. |
||
| 218 | * @access public |
||
| 219 | */ |
||
| 220 | function useFrames() { |
||
| 223 | |||
| 224 | /** |
||
| 225 | * Switches off cookie sending and recieving. |
||
| 226 | * @access public |
||
| 227 | */ |
||
| 228 | function ignoreCookies() { |
||
| 231 | |||
| 232 | /** |
||
| 233 | * Switches back on the cookie sending and recieving. |
||
| 234 | * @access public |
||
| 235 | */ |
||
| 236 | function useCookies() { |
||
| 239 | |||
| 240 | /** |
||
| 241 | * Parses the raw content into a page. Will load further |
||
| 242 | * frame pages unless frames are disabled. |
||
| 243 | * @param SimpleHttpResponse $response Response from fetch. |
||
| 244 | * @param integer $depth Nested frameset depth. |
||
| 245 | * @return SimplePage Parsed HTML. |
||
| 246 | * @access private |
||
| 247 | */ |
||
| 248 | function &_parse($response, $depth = 0) { |
||
| 260 | |||
| 261 | /** |
||
| 262 | * Assembles the parsing machinery and actually parses |
||
| 263 | * a single page. Frees all of the builder memory and so |
||
| 264 | * unjams the PHP memory management. |
||
| 265 | * @param SimpleHttpResponse $response Response from fetch. |
||
| 266 | * @return SimplePage Parsed top level page. |
||
| 267 | * @access protected |
||
| 268 | */ |
||
| 269 | function &_buildPage($response) { |
||
| 276 | |||
| 277 | /** |
||
| 278 | * Fetches a page. Jointly recursive with the _parse() |
||
| 279 | * method as it descends a frameset. |
||
| 280 | * @param string/SimpleUrl $url Target to fetch. |
||
| 281 | * @param SimpleEncoding $encoding GET/POST parameters. |
||
| 282 | * @param integer $depth Nested frameset depth protection. |
||
| 283 | * @return SimplePage Parsed page. |
||
| 284 | * @access private |
||
| 285 | */ |
||
| 286 | function &_fetch($url, $encoding, $depth = 0) { |
||
| 295 | |||
| 296 | /** |
||
| 297 | * Fetches a page or a single frame if that is the current |
||
| 298 | * focus. |
||
| 299 | * @param SimpleUrl $url Target to fetch. |
||
| 300 | * @param SimpleEncoding $parameters GET/POST parameters. |
||
| 301 | * @return string Raw content of page. |
||
| 302 | * @access private |
||
| 303 | */ |
||
| 304 | function _load($url, $parameters) { |
||
| 311 | |||
| 312 | /** |
||
| 313 | * Fetches a page and makes it the current page/frame. |
||
| 314 | * @param string/SimpleUrl $url Target to fetch as string. |
||
| 315 | * @param SimplePostEncoding $parameters POST parameters. |
||
| 316 | * @return string Raw content of page. |
||
| 317 | * @access private |
||
| 318 | */ |
||
| 319 | function _loadPage($url, $parameters) { |
||
| 326 | |||
| 327 | /** |
||
| 328 | * Fetches a frame into the existing frameset replacing the |
||
| 329 | * original. |
||
| 330 | * @param array $frames List of names to drill down. |
||
| 331 | * @param string/SimpleUrl $url Target to fetch as string. |
||
| 332 | * @param SimpleFormEncoding $parameters POST parameters. |
||
| 333 | * @return string Raw content of page. |
||
| 334 | * @access private |
||
| 335 | */ |
||
| 336 | function _loadFrame($frames, $url, $parameters) { |
||
| 340 | |||
| 341 | /** |
||
| 342 | * Removes expired and temporary cookies as if |
||
| 343 | * the browser was closed and re-opened. |
||
| 344 | * @param string/integer $date Time when session restarted. |
||
| 345 | * If omitted then all persistent |
||
| 346 | * cookies are kept. |
||
| 347 | * @access public |
||
| 348 | */ |
||
| 349 | function restart($date = false) { |
||
| 352 | |||
| 353 | /** |
||
| 354 | * Adds a header to every fetch. |
||
| 355 | * @param string $header Header line to add to every |
||
| 356 | * request until cleared. |
||
| 357 | * @access public |
||
| 358 | */ |
||
| 359 | function addHeader($header) { |
||
| 362 | |||
| 363 | /** |
||
| 364 | * Ages the cookies by the specified time. |
||
| 365 | * @param integer $interval Amount in seconds. |
||
| 366 | * @access public |
||
| 367 | */ |
||
| 368 | function ageCookies($interval) { |
||
| 371 | |||
| 372 | /** |
||
| 373 | * Sets an additional cookie. If a cookie has |
||
| 374 | * the same name and path it is replaced. |
||
| 375 | * @param string $name Cookie key. |
||
| 376 | * @param string $value Value of cookie. |
||
| 377 | * @param string $host Host upon which the cookie is valid. |
||
| 378 | * @param string $path Cookie path if not host wide. |
||
| 379 | * @param string $expiry Expiry date. |
||
| 380 | * @access public |
||
| 381 | */ |
||
| 382 | function setCookie($name, $value, $host = false, $path = '/', $expiry = false) { |
||
| 385 | |||
| 386 | /** |
||
| 387 | * Reads the most specific cookie value from the |
||
| 388 | * browser cookies. |
||
| 389 | * @param string $host Host to search. |
||
| 390 | * @param string $path Applicable path. |
||
| 391 | * @param string $name Name of cookie to read. |
||
| 392 | * @return string False if not present, else the |
||
| 393 | * value as a string. |
||
| 394 | * @access public |
||
| 395 | */ |
||
| 396 | function getCookieValue($host, $path, $name) { |
||
| 399 | |||
| 400 | /** |
||
| 401 | * Reads the current cookies for the current URL. |
||
| 402 | * @param string $name Key of cookie to find. |
||
| 403 | * @return string Null if there is no current URL, false |
||
| 404 | * if the cookie is not set. |
||
| 405 | * @access public |
||
| 406 | */ |
||
| 407 | function getCurrentCookieValue($name) { |
||
| 410 | |||
| 411 | /** |
||
| 412 | * Sets the maximum number of redirects before |
||
| 413 | * a page will be loaded anyway. |
||
| 414 | * @param integer $max Most hops allowed. |
||
| 415 | * @access public |
||
| 416 | */ |
||
| 417 | function setMaximumRedirects($max) { |
||
| 420 | |||
| 421 | /** |
||
| 422 | * Sets the maximum number of nesting of framed pages |
||
| 423 | * within a framed page to prevent loops. |
||
| 424 | * @param integer $max Highest depth allowed. |
||
| 425 | * @access public |
||
| 426 | */ |
||
| 427 | function setMaximumNestedFrames($max) { |
||
| 430 | |||
| 431 | /** |
||
| 432 | * Sets the socket timeout for opening a connection. |
||
| 433 | * @param integer $timeout Maximum time in seconds. |
||
| 434 | * @access public |
||
| 435 | */ |
||
| 436 | function setConnectionTimeout($timeout) { |
||
| 439 | |||
| 440 | /** |
||
| 441 | * Sets proxy to use on all requests for when |
||
| 442 | * testing from behind a firewall. Set URL |
||
| 443 | * to false to disable. |
||
| 444 | * @param string $proxy Proxy URL. |
||
| 445 | * @param string $username Proxy username for authentication. |
||
| 446 | * @param string $password Proxy password for authentication. |
||
| 447 | * @access public |
||
| 448 | */ |
||
| 449 | function useProxy($proxy, $username = false, $password = false) { |
||
| 452 | |||
| 453 | /** |
||
| 454 | * Fetches the page content with a HEAD request. |
||
| 455 | * Will affect cookies, but will not change the base URL. |
||
| 456 | * @param string/SimpleUrl $url Target to fetch as string. |
||
| 457 | * @param hash/SimpleHeadEncoding $parameters Additional parameters for |
||
| 458 | * HEAD request. |
||
| 459 | * @return boolean True if successful. |
||
| 460 | * @access public |
||
| 461 | */ |
||
| 462 | function head($url, $parameters = false) { |
||
| 472 | |||
| 473 | /** |
||
| 474 | * Fetches the page content with a simple GET request. |
||
| 475 | * @param string/SimpleUrl $url Target to fetch. |
||
| 476 | * @param hash/SimpleFormEncoding $parameters Additional parameters for |
||
| 477 | * GET request. |
||
| 478 | * @return string Content of page or false. |
||
| 479 | * @access public |
||
| 480 | */ |
||
| 481 | function get($url, $parameters = false) { |
||
| 490 | |||
| 491 | /** |
||
| 492 | * Fetches the page content with a POST request. |
||
| 493 | * @param string/SimpleUrl $url Target to fetch as string. |
||
| 494 | * @param hash/SimpleFormEncoding $parameters POST parameters. |
||
| 495 | * @return string Content of page. |
||
| 496 | * @access public |
||
| 497 | */ |
||
| 498 | function post($url, $parameters = false) { |
||
| 507 | |||
| 508 | /** |
||
| 509 | * Equivalent to hitting the retry button on the |
||
| 510 | * browser. Will attempt to repeat the page fetch. If |
||
| 511 | * there is no history to repeat it will give false. |
||
| 512 | * @return string/boolean Content if fetch succeeded |
||
| 513 | * else false. |
||
| 514 | * @access public |
||
| 515 | */ |
||
| 516 | function retry() { |
||
| 531 | |||
| 532 | /** |
||
| 533 | * Equivalent to hitting the back button on the |
||
| 534 | * browser. The browser history is unchanged on |
||
| 535 | * failure. The page content is refetched as there |
||
| 536 | * is no concept of content caching in SimpleTest. |
||
| 537 | * @return boolean True if history entry and |
||
| 538 | * fetch succeeded |
||
| 539 | * @access public |
||
| 540 | */ |
||
| 541 | function back() { |
||
| 551 | |||
| 552 | /** |
||
| 553 | * Equivalent to hitting the forward button on the |
||
| 554 | * browser. The browser history is unchanged on |
||
| 555 | * failure. The page content is refetched as there |
||
| 556 | * is no concept of content caching in SimpleTest. |
||
| 557 | * @return boolean True if history entry and |
||
| 558 | * fetch succeeded |
||
| 559 | * @access public |
||
| 560 | */ |
||
| 561 | function forward() { |
||
| 571 | |||
| 572 | /** |
||
| 573 | * Retries a request after setting the authentication |
||
| 574 | * for the current realm. |
||
| 575 | * @param string $username Username for realm. |
||
| 576 | * @param string $password Password for realm. |
||
| 577 | * @return boolean True if successful fetch. Note |
||
| 578 | * that authentication may still have |
||
| 579 | * failed. |
||
| 580 | * @access public |
||
| 581 | */ |
||
| 582 | function authenticate($username, $password) { |
||
| 597 | |||
| 598 | /** |
||
| 599 | * Accessor for a breakdown of the frameset. |
||
| 600 | * @return array Hash tree of frames by name |
||
| 601 | * or index if no name. |
||
| 602 | * @access public |
||
| 603 | */ |
||
| 604 | function getFrames() { |
||
| 607 | |||
| 608 | /** |
||
| 609 | * Accessor for current frame focus. Will be |
||
| 610 | * false if no frame has focus. |
||
| 611 | * @return integer/string/boolean Label if any, otherwise |
||
| 612 | * the position in the frameset |
||
| 613 | * or false if none. |
||
| 614 | * @access public |
||
| 615 | */ |
||
| 616 | function getFrameFocus() { |
||
| 619 | |||
| 620 | /** |
||
| 621 | * Sets the focus by index. The integer index starts from 1. |
||
| 622 | * @param integer $choice Chosen frame. |
||
| 623 | * @return boolean True if frame exists. |
||
| 624 | * @access public |
||
| 625 | */ |
||
| 626 | function setFrameFocusByIndex($choice) { |
||
| 629 | |||
| 630 | /** |
||
| 631 | * Sets the focus by name. |
||
| 632 | * @param string $name Chosen frame. |
||
| 633 | * @return boolean True if frame exists. |
||
| 634 | * @access public |
||
| 635 | */ |
||
| 636 | function setFrameFocus($name) { |
||
| 639 | |||
| 640 | /** |
||
| 641 | * Clears the frame focus. All frames will be searched |
||
| 642 | * for content. |
||
| 643 | * @access public |
||
| 644 | */ |
||
| 645 | function clearFrameFocus() { |
||
| 648 | |||
| 649 | /** |
||
| 650 | * Accessor for last error. |
||
| 651 | * @return string Error from last response. |
||
| 652 | * @access public |
||
| 653 | */ |
||
| 654 | function getTransportError() { |
||
| 657 | |||
| 658 | /** |
||
| 659 | * Accessor for current MIME type. |
||
| 660 | * @return string MIME type as string; e.g. 'text/html' |
||
| 661 | * @access public |
||
| 662 | */ |
||
| 663 | function getMimeType() { |
||
| 666 | |||
| 667 | /** |
||
| 668 | * Accessor for last response code. |
||
| 669 | * @return integer Last HTTP response code received. |
||
| 670 | * @access public |
||
| 671 | */ |
||
| 672 | function getResponseCode() { |
||
| 675 | |||
| 676 | /** |
||
| 677 | * Accessor for last Authentication type. Only valid |
||
| 678 | * straight after a challenge (401). |
||
| 679 | * @return string Description of challenge type. |
||
| 680 | * @access public |
||
| 681 | */ |
||
| 682 | function getAuthentication() { |
||
| 685 | |||
| 686 | /** |
||
| 687 | * Accessor for last Authentication realm. Only valid |
||
| 688 | * straight after a challenge (401). |
||
| 689 | * @return string Name of security realm. |
||
| 690 | * @access public |
||
| 691 | */ |
||
| 692 | function getRealm() { |
||
| 695 | |||
| 696 | /** |
||
| 697 | * Accessor for current URL of page or frame if |
||
| 698 | * focused. |
||
| 699 | * @return string Location of current page or frame as |
||
| 700 | * a string. |
||
| 701 | */ |
||
| 702 | function getUrl() { |
||
| 706 | |||
| 707 | /** |
||
| 708 | * Accessor for raw bytes sent down the wire. |
||
| 709 | * @return string Original text sent. |
||
| 710 | * @access public |
||
| 711 | */ |
||
| 712 | function getRequest() { |
||
| 715 | |||
| 716 | /** |
||
| 717 | * Accessor for raw header information. |
||
| 718 | * @return string Header block. |
||
| 719 | * @access public |
||
| 720 | */ |
||
| 721 | function getHeaders() { |
||
| 724 | |||
| 725 | /** |
||
| 726 | * Accessor for raw page information. |
||
| 727 | * @return string Original text content of web page. |
||
| 728 | * @access public |
||
| 729 | */ |
||
| 730 | function getContent() { |
||
| 733 | |||
| 734 | /** |
||
| 735 | * Accessor for plain text version of the page. |
||
| 736 | * @return string Normalised text representation. |
||
| 737 | * @access public |
||
| 738 | */ |
||
| 739 | function getContentAsText() { |
||
| 742 | |||
| 743 | /** |
||
| 744 | * Accessor for parsed title. |
||
| 745 | * @return string Title or false if no title is present. |
||
| 746 | * @access public |
||
| 747 | */ |
||
| 748 | function getTitle() { |
||
| 751 | |||
| 752 | /** |
||
| 753 | * Accessor for a list of all fixed links in current page. |
||
| 754 | * @return array List of urls with scheme of |
||
| 755 | * http or https and hostname. |
||
| 756 | * @access public |
||
| 757 | */ |
||
| 758 | function getAbsoluteUrls() { |
||
| 761 | |||
| 762 | /** |
||
| 763 | * Accessor for a list of all relative links. |
||
| 764 | * @return array List of urls without hostname. |
||
| 765 | * @access public |
||
| 766 | */ |
||
| 767 | function getRelativeUrls() { |
||
| 770 | |||
| 771 | /** |
||
| 772 | * Sets all form fields with that name. |
||
| 773 | * @param string $label Name or label of field in forms. |
||
| 774 | * @param string $value New value of field. |
||
| 775 | * @return boolean True if field exists, otherwise false. |
||
| 776 | * @access public |
||
| 777 | */ |
||
| 778 | function setField($label, $value) { |
||
| 781 | |||
| 782 | /** |
||
| 783 | * Sets all form fields with that name. Will use label if |
||
| 784 | * one is available (not yet implemented). |
||
| 785 | * @param string $name Name of field in forms. |
||
| 786 | * @param string $value New value of field. |
||
| 787 | * @return boolean True if field exists, otherwise false. |
||
| 788 | * @access public |
||
| 789 | */ |
||
| 790 | function setFieldByName($name, $value) { |
||
| 793 | |||
| 794 | /** |
||
| 795 | * Sets all form fields with that id attribute. |
||
| 796 | * @param string/integer $id Id of field in forms. |
||
| 797 | * @param string $value New value of field. |
||
| 798 | * @return boolean True if field exists, otherwise false. |
||
| 799 | * @access public |
||
| 800 | */ |
||
| 801 | function setFieldById($id, $value) { |
||
| 804 | |||
| 805 | /** |
||
| 806 | * Accessor for a form element value within the page. |
||
| 807 | * Finds the first match. |
||
| 808 | * @param string $label Field label. |
||
| 809 | * @return string/boolean A value if the field is |
||
| 810 | * present, false if unchecked |
||
| 811 | * and null if missing. |
||
| 812 | * @access public |
||
| 813 | */ |
||
| 814 | function getField($label) { |
||
| 817 | |||
| 818 | /** |
||
| 819 | * Accessor for a form element value within the page. |
||
| 820 | * Finds the first match. |
||
| 821 | * @param string $name Field name. |
||
| 822 | * @return string/boolean A string if the field is |
||
| 823 | * present, false if unchecked |
||
| 824 | * and null if missing. |
||
| 825 | * @access public |
||
| 826 | */ |
||
| 827 | function getFieldByName($name) { |
||
| 830 | |||
| 831 | /** |
||
| 832 | * Accessor for a form element value within the page. |
||
| 833 | * @param string/integer $id Id of field in forms. |
||
| 834 | * @return string/boolean A string if the field is |
||
| 835 | * present, false if unchecked |
||
| 836 | * and null if missing. |
||
| 837 | * @access public |
||
| 838 | */ |
||
| 839 | function getFieldById($id) { |
||
| 842 | |||
| 843 | /** |
||
| 844 | * Clicks the submit button by label. The owning |
||
| 845 | * form will be submitted by this. |
||
| 846 | * @param string $label Button label. An unlabeled |
||
| 847 | * button can be triggered by 'Submit'. |
||
| 848 | * @param hash $additional Additional form data. |
||
| 849 | * @return string/boolean Page on success. |
||
| 850 | * @access public |
||
| 851 | */ |
||
| 852 | function clickSubmit($label = 'Submit', $additional = false) { |
||
| 861 | |||
| 862 | /** |
||
| 863 | * Clicks the submit button by name attribute. The owning |
||
| 864 | * form will be submitted by this. |
||
| 865 | * @param string $name Button name. |
||
| 866 | * @param hash $additional Additional form data. |
||
| 867 | * @return string/boolean Page on success. |
||
| 868 | * @access public |
||
| 869 | */ |
||
| 870 | function clickSubmitByName($name, $additional = false) { |
||
| 879 | |||
| 880 | /** |
||
| 881 | * Clicks the submit button by ID attribute of the button |
||
| 882 | * itself. The owning form will be submitted by this. |
||
| 883 | * @param string $id Button ID. |
||
| 884 | * @param hash $additional Additional form data. |
||
| 885 | * @return string/boolean Page on success. |
||
| 886 | * @access public |
||
| 887 | */ |
||
| 888 | function clickSubmitById($id, $additional = false) { |
||
| 897 | |||
| 898 | /** |
||
| 899 | * Clicks the submit image by some kind of label. Usually |
||
| 900 | * the alt tag or the nearest equivalent. The owning |
||
| 901 | * form will be submitted by this. Clicking outside of |
||
| 902 | * the boundary of the coordinates will result in |
||
| 903 | * a failure. |
||
| 904 | * @param string $label ID attribute of button. |
||
| 905 | * @param integer $x X-coordinate of imaginary click. |
||
| 906 | * @param integer $y Y-coordinate of imaginary click. |
||
| 907 | * @param hash $additional Additional form data. |
||
| 908 | * @return string/boolean Page on success. |
||
| 909 | * @access public |
||
| 910 | */ |
||
| 911 | function clickImage($label, $x = 1, $y = 1, $additional = false) { |
||
| 920 | |||
| 921 | /** |
||
| 922 | * Clicks the submit image by the name. Usually |
||
| 923 | * the alt tag or the nearest equivalent. The owning |
||
| 924 | * form will be submitted by this. Clicking outside of |
||
| 925 | * the boundary of the coordinates will result in |
||
| 926 | * a failure. |
||
| 927 | * @param string $name Name attribute of button. |
||
| 928 | * @param integer $x X-coordinate of imaginary click. |
||
| 929 | * @param integer $y Y-coordinate of imaginary click. |
||
| 930 | * @param hash $additional Additional form data. |
||
| 931 | * @return string/boolean Page on success. |
||
| 932 | * @access public |
||
| 933 | */ |
||
| 934 | function clickImageByName($name, $x = 1, $y = 1, $additional = false) { |
||
| 943 | |||
| 944 | /** |
||
| 945 | * Clicks the submit image by ID attribute. The owning |
||
| 946 | * form will be submitted by this. Clicking outside of |
||
| 947 | * the boundary of the coordinates will result in |
||
| 948 | * a failure. |
||
| 949 | * @param integer/string $id ID attribute of button. |
||
| 950 | * @param integer $x X-coordinate of imaginary click. |
||
| 951 | * @param integer $y Y-coordinate of imaginary click. |
||
| 952 | * @param hash $additional Additional form data. |
||
| 953 | * @return string/boolean Page on success. |
||
| 954 | * @access public |
||
| 955 | */ |
||
| 956 | function clickImageById($id, $x = 1, $y = 1, $additional = false) { |
||
| 965 | |||
| 966 | /** |
||
| 967 | * Submits a form by the ID. |
||
| 968 | * @param string $id The form ID. No submit button value |
||
| 969 | * will be sent. |
||
| 970 | * @return string/boolean Page on success. |
||
| 971 | * @access public |
||
| 972 | */ |
||
| 973 | function submitFormById($id) { |
||
| 982 | |||
| 983 | /** |
||
| 984 | * Follows a link by label. Will click the first link |
||
| 985 | * found with this link text by default, or a later |
||
| 986 | * one if an index is given. The match ignores case and |
||
| 987 | * white space issues. |
||
| 988 | * @param string $label Text between the anchor tags. |
||
| 989 | * @param integer $index Link position counting from zero. |
||
| 990 | * @return string/boolean Page on success. |
||
| 991 | * @access public |
||
| 992 | */ |
||
| 993 | function clickLink($label, $index = 0) { |
||
| 1004 | |||
| 1005 | /** |
||
| 1006 | * Tests to see if a link is present by label. |
||
| 1007 | * @param string $label Text of value attribute. |
||
| 1008 | * @return boolean True if link present. |
||
| 1009 | * @access public |
||
| 1010 | */ |
||
| 1011 | function isLink($label) { |
||
| 1014 | |||
| 1015 | /** |
||
| 1016 | * Follows a link by id attribute. |
||
| 1017 | * @param string $id ID attribute value. |
||
| 1018 | * @return string/boolean Page on success. |
||
| 1019 | * @access public |
||
| 1020 | */ |
||
| 1021 | function clickLinkById($id) { |
||
| 1028 | |||
| 1029 | /** |
||
| 1030 | * Tests to see if a link is present by ID attribute. |
||
| 1031 | * @param string $id Text of id attribute. |
||
| 1032 | * @return boolean True if link present. |
||
| 1033 | * @access public |
||
| 1034 | */ |
||
| 1035 | function isLinkById($id) { |
||
| 1038 | |||
| 1039 | /** |
||
| 1040 | * Clicks a visible text item. Will first try buttons, |
||
| 1041 | * then links and then images. |
||
| 1042 | * @param string $label Visible text or alt text. |
||
| 1043 | * @return string/boolean Raw page or false. |
||
| 1044 | * @access public |
||
| 1045 | */ |
||
| 1046 | function click($label) { |
||
| 1056 | } |