web_tester.php.svn-base
来自「PHP 知识管理系统(基于树结构的知识管理系统), 英文原版的PHP源码。」· SVN-BASE 代码 · 共 1,541 行 · 第 1/4 页
SVN-BASE
1,541 行
*/ function getCookie($name) { return $this->_browser->getCurrentCookieValue($name); } /** * Sets a cookie in the current browser. * @param string $name Name of cookie. * @param string $value Cookie value. * @param string $host Host upon which the cookie is valid. * @param string $path Cookie path if not host wide. * @param string $expiry Expiry date. * @access public */ function setCookie($name, $value, $host = false, $path = '/', $expiry = false) { $this->_browser->setCookie($name, $value, $host, $path, $expiry); } /** * Accessor for current frame focus. Will be * false if no frame has focus. * @return integer/string/boolean Label if any, otherwise * the position in the frameset * or false if none. * @access public */ function getFrameFocus() { return $this->_browser->getFrameFocus(); } /** * Sets the focus by index. The integer index starts from 1. * @param integer $choice Chosen frame. * @return boolean True if frame exists. * @access public */ function setFrameFocusByIndex($choice) { return $this->_browser->setFrameFocusByIndex($choice); } /** * Sets the focus by name. * @param string $name Chosen frame. * @return boolean True if frame exists. * @access public */ function setFrameFocus($name) { return $this->_browser->setFrameFocus($name); } /** * Clears the frame focus. All frames will be searched * for content. * @access public */ function clearFrameFocus() { return $this->_browser->clearFrameFocus(); } /** * 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) { return $this->_failOnError($this->_browser->click($label)); } /** * Checks for a click target. * @param string $label Visible text or alt text. * @return boolean True if click target. * @access public */ function assertClickable($label, $message = '%s') { return $this->assertTrue( $this->_browser->isClickable($label), sprintf($message, "Click target [$label] should exist")); } /** * Clicks the submit button by label. The owning * form will be submitted by this. * @param string $label Button label. An unlabeled * button can be triggered by 'Submit'. * @param hash $additional Additional form values. * @return boolean/string Page on success, else false. * @access public */ function clickSubmit($label = 'Submit', $additional = false) { return $this->_failOnError( $this->_browser->clickSubmit($label, $additional)); } /** * Clicks the submit button by name attribute. The owning * form will be submitted by this. * @param string $name Name attribute of button. * @param hash $additional Additional form values. * @return boolean/string Page on success. * @access public */ function clickSubmitByName($name, $additional = false) { return $this->_failOnError( $this->_browser->clickSubmitByName($name, $additional)); } /** * Clicks the submit button by ID attribute. The owning * form will be submitted by this. * @param string $id ID attribute of button. * @param hash $additional Additional form values. * @return boolean/string Page on success. * @access public */ function clickSubmitById($id, $additional = false) { return $this->_failOnError( $this->_browser->clickSubmitById($id, $additional)); } /** * Checks for a valid button label. * @param string $label Visible text. * @return boolean True if click target. * @access public */ function assertSubmit($label, $message = '%s') { return $this->assertTrue( $this->_browser->isSubmit($label), sprintf($message, "Submit button [$label] should exist")); } /** * Clicks the submit image by some kind of label. Usually * the alt tag or the nearest equivalent. The owning * form will be submitted by this. Clicking outside of * the boundary of the coordinates will result in * a failure. * @param string $label Alt attribute of button. * @param integer $x X-coordinate of imaginary click. * @param integer $y Y-coordinate of imaginary click. * @param hash $additional Additional form values. * @return boolean/string Page on success. * @access public */ function clickImage($label, $x = 1, $y = 1, $additional = false) { return $this->_failOnError( $this->_browser->clickImage($label, $x, $y, $additional)); } /** * Clicks the submit image by the name. Usually * the alt tag or the nearest equivalent. The owning * form will be submitted by this. Clicking outside of * the boundary of the coordinates will result in * a failure. * @param string $name Name attribute of button. * @param integer $x X-coordinate of imaginary click. * @param integer $y Y-coordinate of imaginary click. * @param hash $additional Additional form values. * @return boolean/string Page on success. * @access public */ function clickImageByName($name, $x = 1, $y = 1, $additional = false) { return $this->_failOnError( $this->_browser->clickImageByName($name, $x, $y, $additional)); } /** * Clicks the submit image by ID attribute. The owning * form will be submitted by this. Clicking outside of * the boundary of the coordinates will result in * a failure. * @param integer/string $id ID attribute of button. * @param integer $x X-coordinate of imaginary click. * @param integer $y Y-coordinate of imaginary click. * @param hash $additional Additional form values. * @return boolean/string Page on success. * @access public */ function clickImageById($id, $x = 1, $y = 1, $additional = false) { return $this->_failOnError( $this->_browser->clickImageById($id, $x, $y, $additional)); } /** * Checks for a valid image with atht alt text or title. * @param string $label Visible text. * @return boolean True if click target. * @access public */ function assertImage($label, $message = '%s') { return $this->assertTrue( $this->_browser->isImage($label), sprintf($message, "Image with text [$label] should exist")); } /** * Submits a form by the ID. * @param string $id Form ID. No button information * is submitted this way. * @return boolean/string Page on success. * @access public */ function submitFormById($id) { return $this->_failOnError($this->_browser->submitFormById($id)); } /** * Follows a link by name. Will click the first link * found with this link text by default, or a later * one if an index is given. Match is case insensitive * with normalised space. * @param string $label Text between the anchor tags. * @param integer $index Link position counting from zero. * @return boolean/string Page on success. * @access public */ function clickLink($label, $index = 0) { return $this->_failOnError($this->_browser->clickLink($label, $index)); } /** * Follows a link by id attribute. * @param string $id ID attribute value. * @return boolean/string Page on success. * @access public */ function clickLinkById($id) { return $this->_failOnError($this->_browser->clickLinkById($id)); } /** * Tests for the presence of a link label. Match is * case insensitive with normalised space. * @param string $label Text between the anchor tags. * @param mixed $expected Expected URL or expectation object. * @param string $message Message to display. Default * can be embedded with %s. * @return boolean True if link present. * @access public */ function assertLink($label, $expected = true, $message = '%s') { $url = $this->_browser->getLink($label); if ($expected === true || ($expected !== true && $url === false)) { return $this->assertTrue($url !== false, sprintf($message, "Link [$label] should exist")); } if (! SimpleExpectation::isExpectation($expected)) { $expected = new IdenticalExpectation($expected); } return $this->assert($expected, $url->asString(), sprintf($message, "Link [$label] should match")); } /** * Tests for the non-presence of a link label. Match is * case insensitive with normalised space. * @param string/integer $label Text between the anchor tags * or ID attribute. * @param string $message Message to display. Default * can be embedded with %s. * @return boolean True if link missing. * @access public */ function assertNoLink($label, $message = '%s') { return $this->assertTrue( $this->_browser->getLink($label) === false, sprintf($message, "Link [$label] should not exist")); } /** * Tests for the presence of a link id attribute. * @param string $id Id attribute value. * @param mixed $expected Expected URL or expectation object. * @param string $message Message to display. Default * can be embedded with %s. * @return boolean True if link present. * @access public */ function assertLinkById($id, $expected = true, $message = '%s') { $url = $this->_browser->getLinkById($id); if ($expected === true) { return $this->assertTrue($url !== false, sprintf($message, "Link ID [$id] should exist")); } if (! SimpleExpectation::isExpectation($expected)) { $expected = new IdenticalExpectation($expected); } return $this->assert($expected, $url->asString(), sprintf($message, "Link ID [$id] should match")); } /** * Tests for the non-presence of a link label. Match is * case insensitive with normalised space. * @param string $id Id attribute value. * @param string $message Message to display. Default * can be embedded with %s. * @return boolean True if link missing. * @access public */ function assertNoLinkById($id, $message = '%s') { return $this->assertTrue( $this->_browser->getLinkById($id) === false, sprintf($message, "Link ID [$id] should not exist")); } /** * Sets all form fields with that label, or name if there * is no label attached. * @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($label, $value, $position=false) { return $this->_browser->setField($label, $value, $position); } /** * Sets all form fields with that name. * @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 setFieldByName($name, $value, $position=false) { return $this->_browser->setFieldByName($name, $value, $position); } /** * Sets all form fields with that id. * @param string/integer $id Id of field in forms. * @param string $value New value of field. * @return boolean True if field exists, otherwise false. * @access public */ function setFieldById($id, $value) { return $this->_browser->setFieldById($id, $value); } /** * Confirms that the form element is currently set * to the expected value. A missing form will always * fail. If no value is given then only the existence * of the field is checked. * @param string $name Name of field in forms. * @param mixed $expected Expected string/array value or * false for unset fields. * @param string $message Message to display. Default * can be embedded with %s. * @return boolean True if pass. * @access public */ function assertField($label, $expected = true, $message = '%s') { $value = $this->_browser->getField($label); return $this->_assertFieldValue($label, $value, $expected, $message); } /** * Confirms that the form element is currently set * to the expected value. A missing form element will always * fail. If no value is given then only the existence * of the field is checked. * @param string $name Name of field in forms. * @param mixed $expected Expected string/array value or * false for unset fields. * @param string $message Message to display. Default * can be embedded with %s. * @return boolean True if pass. * @access public */ function assertFieldByName($name, $expected = true, $message = '%s') { $value = $this->_browser->getFieldByName($name); return $this->_assertFieldValue($name, $value, $expected, $message); } /** * Confirms that the form element is currently set * to the expected value. A missing form will always * fail. If no ID is given then only the existence * of the field is checked. * @param string/integer $id Name of field in forms. * @param mixed $expected Expected string/array value or * false for unset fields. * @param string $message Message to display. Default * can be embedded with %s.
⌨️ 快捷键说明
复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?