Properties

$sessionID

$sessionID : string

Type

string

Methods

create()

create(string  $url = 'http://localhost:4444/wd/hub', \DesiredCapabilities  $desired_capabilities = null, integer  $timeout_in_ms = 300000) : \RemoteWebDriver

Construct the RemoteWebDriver by a desired capabilities.

Parameters

string $url

The url of the remote server

\DesiredCapabilities $desired_capabilities

The desired capabilities

integer $timeout_in_ms

Returns

\RemoteWebDriver

createBySessionID()

createBySessionID(string  $session_id, string  $url = 'http://localhost:4444/wd/hub') : \RemoteWebDriver

[Experimental] Construct the RemoteWebDriver by an existing session.

This constructor can boost the performance a lot by reusing the same browser for the whole test suite. You do not have to pass the desired capabilities because the session was created before.

Parameters

string $session_id

The existing session id

string $url

The url of the remote server

Returns

\RemoteWebDriver

close()

close() : \RemoteWebDriver

Close the current window.

Returns

\RemoteWebDriver —

The current instance.

findElement()

findElement(\WebDriverBy  $by) : \RemoteWebElement

Find the first WebDriverElement using the given mechanism.

Parameters

\WebDriverBy $by

Returns

\RemoteWebElement —

NoSuchElementException is thrown in HttpCommandExecutor if no element is found.

findElements()

findElements(\WebDriverBy  $by) : array<mixed,\RemoteWebElement>

Find all WebDriverElements within the current page using the given mechanism.

Parameters

\WebDriverBy $by

Returns

array<mixed,\RemoteWebElement> —

A list of all WebDriverElements, or an empty array if nothing matches

get()

get(string  $url) : \RemoteWebDriver

Load a new web page in the current browser window.

Parameters

string $url

Returns

\RemoteWebDriver —

The current instance.

getCurrentURL()

getCurrentURL() : string

Get a string representing the current URL that the browser is looking at.

Returns

string —

The current URL.

getPageSource()

getPageSource() : string

Get the source of the last loaded page.

Returns

string —

The current page source.

getTitle()

getTitle() : string

Get the title of the current page.

Returns

string —

The title of the current page.

getWindowHandle()

getWindowHandle() : string

Return an opaque handle to this window that uniquely identifies it within this driver instance.

Returns

string —

The current window handle.

getWindowHandles()

getWindowHandles() : array

Get all window handles available to the current session.

Returns

array —

An array of string containing all available window handles.

quit()

quit() : void

Quits this driver, closing every associated window.

executeScript()

executeScript(string  $script, array  $arguments = array()) : mixed

Inject a snippet of JavaScript into the page for execution in the context of the currently selected frame. The executed script is assumed to be synchronous and the result of evaluating the script will be returned.

Parameters

string $script

The script to inject.

array $arguments

The arguments of the script.

Returns

mixed —

The return value of the script.

executeAsyncScript()

executeAsyncScript(string  $script, array  $arguments = array()) : mixed

Inject a snippet of JavaScript into the page for asynchronous execution in the context of the currently selected frame.

The driver will pass a callback as the last argument to the snippet, and block until the callback is invoked.

Parameters

string $script

The script to inject.

array $arguments

The arguments of the script.

Returns

mixed —

The value passed by the script to the callback.

takeScreenshot()

takeScreenshot(string  $save_as = null) : string

Take a screenshot of the current page.

Parameters

string $save_as

The path of the screenshot to be saved.

Returns

string —

The screenshot in PNG format.

wait()

wait(integer  $timeout_in_second = 30, integer  $interval_in_millisecond = 250) : \WebDriverWait

Construct a new WebDriverWait by the current WebDriver instance.

Sample usage:

$driver->wait(20, 1000)->until(

WebDriverExpectedCondition::titleIs('WebDriver Page')

);

Parameters

integer $timeout_in_second
integer $interval_in_millisecond

Returns

\WebDriverWait

manage()

manage() : \WebDriverOptions

An abstraction for managing stuff you would do in a browser menu. For example, adding and deleting cookies.

Returns

\WebDriverOptions

navigate()

navigate() : \WebDriverNavigation

An abstraction allowing the driver to access the browser's history and to navigate to a given URL.

Returns

\WebDriverNavigation

switchTo()

switchTo() : \WebDriverTargetLocator

Switch to a different window or frame.

Returns

\WebDriverTargetLocator

action()

action() : \WebDriverActions

Construct a new action builder.

Returns

\WebDriverActions

getActiveElement()

getActiveElement() : \RemoteWebElement

Get the element on the page that currently has focus.

Returns

\RemoteWebElement

setCommandExecutor()

setCommandExecutor(\WebDriverCommandExecutor  $executor) : \RemoteWebDriver

Set the command executor of this RemoteWebdrver

Parameters

\WebDriverCommandExecutor $executor

Returns

\RemoteWebDriver

getCommandExecutor()

getCommandExecutor() : \HttpCommandExecutor

Set the command executor of this RemoteWebdriver

Returns

\HttpCommandExecutor

setSessionID()

setSessionID(string  $session_id) : \RemoteWebDriver

Set the session id of the RemoteWebDriver.

Parameters

string $session_id

Returns

\RemoteWebDriver

getSessionID()

getSessionID() : string

Get current selenium sessionID

Returns

string —

sessionID

execute()

execute(  $command_name,   $params = array()) : mixed

Parameters

$command_name
$params

Returns

mixed

__construct()

__construct() 

getExecuteMethod()

getExecuteMethod() 

prepareScriptArguments()

prepareScriptArguments(array  $arguments) : array

Prepare arguments for JavaScript injection

Parameters

array $arguments

Returns

array

newElement()

newElement(string  $id) : \RemoteWebElement

Return the WebDriverElement with the given id.

Parameters

string $id

The id of the element to be created.

Returns

\RemoteWebElement