HumHub Documentation (unofficial)

RemoteWebDriver
in package
implements WebDriver, JavaScriptExecutor, WebDriverHasInputDevices

Table of Contents

Interfaces

WebDriver
The interface for WebDriver.
JavaScriptExecutor
WebDriver interface implemented by drivers that support JavaScript.
WebDriverHasInputDevices
Interface implemented by each driver that allows access to the input devices.

Properties

$capabilities  : WebDriverCapabilities|null
$executeMethod  : RemoteExecuteMethod
$executor  : HttpCommandExecutor|null
$isW3cCompliant  : bool
$keyboard  : RemoteKeyboard
$mouse  : RemoteMouse
$sessionID  : string
$touch  : RemoteTouchScreen

Methods

action()  : WebDriverActions
Construct a new action builder.
close()  : RemoteWebDriver
Close the current window.
create()  : static
Construct the RemoteWebDriver by a desired capabilities.
createBySessionID()  : static
[Experimental] Construct the RemoteWebDriver by an existing session.
execute()  : mixed
executeAsyncScript()  : mixed
Inject a snippet of JavaScript into the page for asynchronous execution in the context of the currently selected frame.
executeCustomCommand()  : mixed|null
Execute custom commands on remote end.
executeScript()  : mixed
Inject a snippet of JavaScript into the page for execution in the context of the currently selected frame.
findElement()  : RemoteWebElement
Find the first WebDriverElement using the given mechanism.
findElements()  : array<string|int, RemoteWebElement>
Find all WebDriverElements within the current page using the given mechanism.
get()  : RemoteWebDriver
Load a new web page in the current browser window.
getAllSessions()  : array<string|int, mixed>
Returns a list of the currently active sessions.
getCapabilities()  : WebDriverCapabilities|null
Get capabilities of the RemoteWebDriver.
getCommandExecutor()  : HttpCommandExecutor
Get the command executor of this RemoteWebdriver
getCurrentURL()  : string
Get a string representing the current URL that the browser is looking at.
getKeyboard()  : RemoteKeyboard
getMouse()  : RemoteMouse
getPageSource()  : string
Get the source of the last loaded page.
getSessionID()  : string
Get current selenium sessionID
getStatus()  : mixed
Status returns information about whether a remote end is in a state in which it can create new sessions.
getTitle()  : string
Get the title of the current page.
getTouch()  : RemoteTouchScreen
getWindowHandle()  : string
Return an opaque handle to this window that uniquely identifies it within this driver instance.
getWindowHandles()  : array<string|int, mixed>
Get all window handles available to the current session.
manage()  : WebDriverOptions
An abstraction for managing stuff you would do in a browser menu. For example, adding and deleting cookies.
navigate()  : WebDriverNavigation
An abstraction allowing the driver to access the browser's history and to navigate to a given URL.
newWindow()  : WebDriver
Create a new top-level browsing context.
quit()  : mixed
Quits this driver, closing every associated window.
switchTo()  : RemoteTargetLocator
Switch to a different window or frame.
takeScreenshot()  : string
Take a screenshot of the current page.
wait()  : WebDriverWait
Construct a new WebDriverWait by the current WebDriver instance.
__construct()  : mixed
castToDesiredCapabilitiesObject()  : DesiredCapabilities
Cast legacy types (array or null) to DesiredCapabilities object. To be removed in future when instance of DesiredCapabilities will be required.
getExecuteMethod()  : RemoteExecuteMethod
newElement()  : RemoteWebElement
Return the WebDriverElement with the given id.
prepareScriptArguments()  : array<string|int, mixed>
Prepare arguments for JavaScript injection
readExistingCapabilitiesFromSeleniumGrid()  : DesiredCapabilities

Properties

Methods

create()

Construct the RemoteWebDriver by a desired capabilities.

public static create([string $selenium_server_url = 'http://localhost:4444/wd/hub' ][, DesiredCapabilities|array<string|int, mixed> $desired_capabilities = null ][, int|null $connection_timeout_in_ms = null ][, int|null $request_timeout_in_ms = null ][, string|null $http_proxy = null ][, int|null $http_proxy_port = null ][, DesiredCapabilities $required_capabilities = null ]) : static
Parameters
$selenium_server_url : string = 'http://localhost:4444/wd/hub'

The url of the remote Selenium WebDriver server

$desired_capabilities : DesiredCapabilities|array<string|int, mixed> = null

The desired capabilities

$connection_timeout_in_ms : int|null = null

Set timeout for the connect phase to remote Selenium WebDriver server

$request_timeout_in_ms : int|null = null

Set the maximum time of a request to remote Selenium WebDriver server

$http_proxy : string|null = null

The proxy to tunnel requests to the remote Selenium WebDriver through

$http_proxy_port : int|null = null

The proxy port to tunnel requests to the remote Selenium WebDriver through

$required_capabilities : DesiredCapabilities = null

The required capabilities

Return values
static

createBySessionID()

[Experimental] Construct the RemoteWebDriver by an existing session.

public static createBySessionID(string $session_id[, string $selenium_server_url = 'http://localhost:4444/wd/hub' ][, int|null $connection_timeout_in_ms = null ][, int|null $request_timeout_in_ms = null ]) : static

This constructor can boost the performance by reusing the same browser for the whole test suite. On the other hand, because the browser is not pristine, this may lead to flaky and dependent tests. So carefully consider the tradeoffs.

To create the instance, we need to know Capabilities of the previously created session. You can either pass them in $existingCapabilities parameter, or we will attempt to receive them from the Selenium Grid server. However, if Capabilities were not provided and the attempt to get them was not successful, exception will be thrown.

Parameters
$session_id : string

The existing session id

$selenium_server_url : string = 'http://localhost:4444/wd/hub'

The url of the remote Selenium WebDriver server

$connection_timeout_in_ms : int|null = null

Set timeout for the connect phase to remote Selenium WebDriver server

$request_timeout_in_ms : int|null = null

Set the maximum time of a request to remote Selenium WebDriver server

Return values
static

execute()

public execute(mixed $command_name[, mixed $params = [] ]) : mixed
Parameters
$command_name : mixed
$params : mixed = []

executeAsyncScript()

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

public executeAsyncScript(string $script[, array<string|int, mixed> $arguments = [] ]) : mixed

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

You may need to define script timeout using setScriptTimeout() method of WebDriverTimeouts first.

Parameters
$script : string

The script to inject.

$arguments : array<string|int, mixed> = []

The arguments of the script.

Return values
mixed

The value passed by the script to the callback.

executeCustomCommand()

Execute custom commands on remote end.

public executeCustomCommand(string $endpointUrl[, string $method = 'GET' ][, array<string|int, mixed> $params = [] ]) : mixed|null

For example vendor-specific commands or other commands not implemented by php-webdriver.

Parameters
$endpointUrl : string
$method : string = 'GET'
$params : array<string|int, mixed> = []
Tags
see
https://github.com/php-webdriver/php-webdriver/wiki/Custom-commands
Return values
mixed|null

executeScript()

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

public executeScript(string $script[, array<string|int, mixed> $arguments = [] ]) : mixed

The executed script is assumed to be synchronous and the result of evaluating the script will be returned.

Parameters
$script : string

The script to inject.

$arguments : array<string|int, mixed> = []

The arguments of the script.

Return values
mixed

The return value of the script.

getAllSessions()

Returns a list of the currently active sessions.

public static getAllSessions([string $selenium_server_url = 'http://localhost:4444/wd/hub' ][, int $timeout_in_ms = 30000 ]) : array<string|int, mixed>
Parameters
$selenium_server_url : string = 'http://localhost:4444/wd/hub'

The url of the remote Selenium WebDriver server

$timeout_in_ms : int = 30000
Tags
deprecated

Removed in W3C WebDriver.

Return values
array<string|int, mixed>

getCurrentURL()

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

public getCurrentURL() : string
Return values
string

The current URL.

getPageSource()

Get the source of the last loaded page.

public getPageSource() : string
Return values
string

The current page source.

getSessionID()

Get current selenium sessionID

public getSessionID() : string
Return values
string

getStatus()

Status returns information about whether a remote end is in a state in which it can create new sessions.

public getStatus() : mixed

getTitle()

Get the title of the current page.

public getTitle() : string
Return values
string

The title of the current page.

getWindowHandle()

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

public getWindowHandle() : string
Return values
string

The current window handle.

getWindowHandles()

Get all window handles available to the current session.

public getWindowHandles() : array<string|int, mixed>

Note: Do not use end($driver->getWindowHandles()) to find the last open window, for proper solution see: https://github.com/php-webdriver/php-webdriver/wiki/Alert,-tabs,-frames,-iframes#switch-to-the-new-window

Return values
array<string|int, mixed>

An array of string containing all available window handles.

newWindow()

Create a new top-level browsing context.

public newWindow() : WebDriver
Tags
codeCoverageIgnore
deprecated

Use $driver->switchTo()->newWindow()

Return values
WebDriver

The current instance.

quit()

Quits this driver, closing every associated window.

public quit() : mixed

takeScreenshot()

Take a screenshot of the current page.

public takeScreenshot([string $save_as = null ]) : string
Parameters
$save_as : string = null

The path of the screenshot to be saved.

Return values
string

The screenshot in PNG format.

wait()

Construct a new WebDriverWait by the current WebDriver instance.

public wait([int $timeout_in_second = 30 ][, int $interval_in_millisecond = 250 ]) : WebDriverWait

Sample usage:

  $driver->wait(20, 1000)->until(
    WebDriverExpectedCondition::titleIs('WebDriver Page')
  );
Parameters
$timeout_in_second : int = 30
$interval_in_millisecond : int = 250
Return values
WebDriverWait

castToDesiredCapabilitiesObject()

Cast legacy types (array or null) to DesiredCapabilities object. To be removed in future when instance of DesiredCapabilities will be required.

protected static castToDesiredCapabilitiesObject([array<string|int, mixed>|DesiredCapabilities|null $desired_capabilities = null ]) : DesiredCapabilities
Parameters
$desired_capabilities : array<string|int, mixed>|DesiredCapabilities|null = null
Return values
DesiredCapabilities

prepareScriptArguments()

Prepare arguments for JavaScript injection

protected prepareScriptArguments(array<string|int, mixed> $arguments) : array<string|int, mixed>
Parameters
$arguments : array<string|int, mixed>
Return values
array<string|int, mixed>

        
On this page

Search results