Starts with a fresh browser with no cookie or any other state information. The exception is that a default proxy will be set up if specified in the options.
SimpleBrowser
SimpleBrowser
()
Adds a header to every fetch.
void
addHeader
(string $header)
-
string
$header: Header line to add to every request until cleared.
Ages the cookies by the specified time.
void
ageCookies
(integer $interval)
-
integer
$interval: Amount in seconds.
Retries a request after setting the authentication for the current realm.
boolean
authenticate
(string $username, string $password)
-
string
$username: Username for realm.
-
string
$password: Password for realm.
Equivalent to hitting the back button on the browser. The browser history is unchanged on failure. The page content is refetched as there is no concept of content caching in SimpleTest.
boolean
back
()
Clears the frame focus. All frames will be searched for content.
void
clearFrameFocus
()
Clicks a visible text item. Will first try buttons, then links and then images.
string/boolean
click
(string $label)
-
string
$label: Visible text or alt text.
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.
string/boolean
clickImage
(string $label, [integer $x = 1], [integer $y = 1], [hash $additional = false])
-
string
$label: ID attribute of button.
-
integer
$x: X-coordinate of imaginary click.
-
integer
$y: Y-coordinate of imaginary click.
-
hash
$additional: Additional form data.
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.
string/boolean
clickImageById
(integer/string $id, [integer $x = 1], [integer $y = 1], [hash $additional = false])
-
integer/string
$id: ID attribute of button.
-
integer
$x: X-coordinate of imaginary click.
-
integer
$y: Y-coordinate of imaginary click.
-
hash
$additional: Additional form data.
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.
string/boolean
clickImageByName
(string $name, [integer $x = 1], [integer $y = 1], [hash $additional = false])
-
string
$name: Name attribute of button.
-
integer
$x: X-coordinate of imaginary click.
-
integer
$y: Y-coordinate of imaginary click.
-
hash
$additional: Additional form data.
Follows a link by label. Will click the first link found with this link text by default, or a later one if an index is given. The match ignores case and white space issues.
string/boolean
clickLink
(string $label, integer $index)
-
string
$label: Text between the anchor tags.
-
integer
$index: Link position counting from zero.
Follows a link by id attribute.
string/boolean
clickLinkById
(string $id)
-
string
$id: ID attribute value.
Clicks the submit button by label. The owning form will be submitted by this.
string/boolean
clickSubmit
([string $label = 'Submit'], [hash $additional = false])
-
string
$label: Button label. An unlabeled button can be triggered by 'Submit'.
-
hash
$additional: Additional form data.
Clicks the submit button by ID attribute of the button itself. The owning form will be submitted by this.
string/boolean
clickSubmitById
(string $id, [hash $additional = false])
-
string
$id: Button ID.
-
hash
$additional: Additional form data.
Clicks the submit button by name attribute. The owning form will be submitted by this.
string/boolean
clickSubmitByName
(string $name, [hash $additional = false])
-
string
$name: Button name.
-
hash
$additional: Additional form data.
Equivalent to hitting the forward button on the browser. The browser history is unchanged on failure. The page content is refetched as there is no concept of content caching in SimpleTest.
boolean
forward
()
Fetches the page content with a simple GET request.
string
get
(string/SimpleUrl $url, [hash/SimpleFormEncoding $parameters = false])
-
string/SimpleUrl
$url: Target to fetch.
-
hash/SimpleFormEncoding
$parameters: Additional parameters for GET request.
Accessor for last Authentication type. Only valid straight after a challenge (401).
string
getAuthentication
()
Accessor for base URL of page if set via BASE tag
string
getBaseUrl
()
Accessor for raw page information.
string
getContent
()
Accessor for plain text version of the page.
string
getContentAsText
()
Reads the most specific cookie value from the browser cookies.
string
getCookieValue
(string $host, string $path, string $name)
-
string
$host: Host to search.
-
string
$path: Applicable path.
-
string
$name: Name of cookie to read.
Reads the current cookies for the current URL.
string
getCurrentCookieValue
(string $name)
-
string
$name: Key of cookie to find.
Accessor for a form element value within the page.
Finds the first match.
string/boolean
getField
(string $label)
-
string
$label: Field label.
Accessor for a form element value within the page.
string/boolean
getFieldById
(string/integer $id)
-
string/integer
$id: Id of field in forms.
Accessor for a form element value within the page.
Finds the first match.
string/boolean
getFieldByName
(string $name)
-
string
$name: Field name.
Accessor for current frame focus. Will be false if no frame has focus.
integer/string/boolean
getFrameFocus
()
Accessor for a breakdown of the frameset.
array
getFrames
()
Accessor for raw header information.
string
getHeaders
()
Finds a URL by label. Will find the first link found with this link text by default, or a later one if an index is given. The match ignores case and white space issues.
string/boolean
getLink
(string $label, integer $index)
-
string
$label: Text between the anchor tags.
-
integer
$index: Link position counting from zero.
Finds a link by id attribute.
string/boolean
getLinkById
(string $id)
-
string
$id: ID attribute value.
Accessor for current MIME type.
string
getMimeType
()
Accessor for last Authentication realm. Only valid straight after a challenge (401).
string
getRealm
()
Accessor for raw bytes sent down the wire.
string
getRequest
()
Accessor for last response code.
integer
getResponseCode
()
Accessor for parsed title.
string
getTitle
()
Accessor for last error.
string
getTransportError
()
Accessor for current URL of page or frame if focused.
string
getUrl
()
Accessor for a list of all links in current page.
array
getUrls
()
Fetches the page content with a HEAD request.
Will affect cookies, but will not change the base URL.
boolean
head
(string/SimpleUrl $url, [hash/SimpleHeadEncoding $parameters = false])
-
string/SimpleUrl
$url: Target to fetch as string.
-
hash/SimpleHeadEncoding
$parameters: Additional parameters for HEAD request.
Switches off cookie sending and recieving.
void
ignoreCookies
()
Disables frames support. Frames will not be fetched and the frameset page will be used instead.
void
ignoreFrames
()
Tests to see if a click target exists.
boolean
isClickable
(string $label)
-
string
$label: Visible text or alt text.
Tests to see if an image exists with this title or alt text.
boolean
isImage
(string $label)
-
string
$label: Image text.
Tests to see if a submit button exists with this label.
boolean
isSubmit
(string $label)
-
string
$label: Button label.
Fetches the page content with a POST request.
string
post
(string/SimpleUrl $url, [hash/SimpleFormEncoding $parameters = false])
-
string/SimpleUrl
$url: Target to fetch as string.
-
hash/SimpleFormEncoding
$parameters: POST parameters.
Removes expired and temporary cookies as if the browser was closed and re-opened.
void
restart
([string/integer $date = false])
-
string/integer
$date: Time when session restarted. If omitted then all persistent cookies are kept.
Equivalent to hitting the retry button on the browser. Will attempt to repeat the page fetch. If there is no history to repeat it will give false.
string/boolean
retry
()
Sets the socket timeout for opening a connection.
void
setConnectionTimeout
(integer $timeout)
-
integer
$timeout: Maximum time in seconds.
Sets an additional cookie. If a cookie has the same name and path it is replaced.
void
setCookie
(string $name, string $value, [string $host = false], [string $path = '/'], [string $expiry = false])
-
string
$name: Cookie key.
-
string
$value: Value of cookie.
-
string
$host: Host upon which the cookie is valid.
-
string
$path: Cookie path if not host wide.
-
string
$expiry: Expiry date.
Sets all form fields with that name.
boolean
setField
(string $label, string $value, [ $position = false])
-
string
$label: Name or label of field in forms.
-
string
$value: New value of field.
-
$position
Sets all form fields with that id attribute.
boolean
setFieldById
(string/integer $id, string $value)
-
string/integer
$id: Id of field in forms.
-
string
$value: New value of field.
Sets all form fields with that name. Will use label if one is available (not yet implemented).
boolean
setFieldByName
(string $name, string $value, [ $position = false])
-
string
$name: Name of field in forms.
-
string
$value: New value of field.
-
$position
Sets the focus by name.
boolean
setFrameFocus
(string $name)
-
string
$name: Chosen frame.
Sets the focus by index. The integer index starts from 1.
boolean
setFrameFocusByIndex
(integer $choice)
-
integer
$choice: Chosen frame.
Sets the maximum number of nesting of framed pages within a framed page to prevent loops.
void
setMaximumNestedFrames
(integer $max)
-
integer
$max: Highest depth allowed.
Sets the maximum number of redirects before a page will be loaded anyway.
void
setMaximumRedirects
(integer $max)
-
integer
$max: Most hops allowed.
Submits a form by the ID.
string/boolean
submitFormById
(string $id)
-
string
$id: The form ID. No submit button value will be sent.
Switches back on the cookie sending and recieving.
void
useCookies
()
Enables frames support. Frames will be fetched from now on.
void
useFrames
()
Sets proxy to use on all requests for when testing from behind a firewall. Set URL to false to disable.
void
useProxy
(string $proxy, [string $username = false], [string $password = false])
-
string
$proxy: Proxy URL.
-
string
$username: Proxy username for authentication.
-
string
$password: Proxy password for authentication.
Assembles the parsing machinery and actually parses a single page. Frees all of the builder memory and so unjams the PHP memory management.
Creates a new empty history list.
Creates the underlying user agent.
SimpleFetcher
&_createUserAgent
()