LocalWebDriver
abstract class LocalWebDriver extends RemoteWebDriver (View source)
Properties
protected HttpCommandExecutor|null | $executor | from RemoteWebDriver | |
protected WebDriverCapabilities|null | $capabilities | from RemoteWebDriver | |
protected string | $sessionID | from RemoteWebDriver | |
protected RemoteMouse | $mouse | from RemoteWebDriver | |
protected RemoteKeyboard | $keyboard | from RemoteWebDriver | |
protected RemoteTouchScreen | $touch | from RemoteWebDriver | |
protected RemoteExecuteMethod | $executeMethod | from RemoteWebDriver | |
protected bool | $isW3cCompliant | from RemoteWebDriver |
Methods
No description
Construct the RemoteWebDriver by a desired capabilities.
[Experimental] Construct the RemoteWebDriver by an existing session.
Find all WebDriverElements within the current page using the given mechanism.
Get a string representing the current URL that the browser is looking at.
Return an opaque handle to this window that uniquely identifies it within this driver instance.
Get all window handles available to the current session.
Inject a snippet of JavaScript into the page for execution in the context of the currently selected frame.
Inject a snippet of JavaScript into the page for asynchronous execution in the context of the currently selected frame.
Take a screenshot of the current page.
Status returns information about whether a remote end is in a state in which it can create new sessions.
Construct a new WebDriverWait by the current WebDriver instance.
An abstraction for managing stuff you would do in a browser menu. For example, adding and deleting cookies.
An abstraction allowing the driver to access the browser's history and to navigate to a given URL.
Set the command executor of this RemoteWebdriver
Get the command executor of this RemoteWebdriver
Get capabilities of the RemoteWebDriver.
Returns a list of the currently active sessions.
Execute custom commands on remote end.
Create instance based on response to NEW_SESSION command.
Prepare arguments for JavaScript injection
Return the WebDriverElement with the given id.
Cast legacy types (array or null) to DesiredCapabilities object. To be removed in future when instance of DesiredCapabilities will be required.
No description
Details
protected
__construct(HttpCommandExecutor $commandExecutor, string $sessionId, WebDriverCapabilities $capabilities, bool $isW3cCompliant = false)
No description
static RemoteWebDriver
create(string $selenium_server_url = 'http://localhost:4444/wd/hub', DesiredCapabilities|array $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)
Construct the RemoteWebDriver by a desired capabilities.
static RemoteWebDriver
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)
[Experimental] Construct the RemoteWebDriver by an existing session.
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.
WebDriver
close()
Close the current window.
WebDriver
newWindow()
deprecated
deprecated
Create a new top-level browsing context.
WebDriverElement
findElement(WebDriverBy $by)
Find the first WebDriverElement using the given mechanism.
WebDriverElement[]
findElements(WebDriverBy $by)
Find all WebDriverElements within the current page using the given mechanism.
WebDriver
get(string $url)
Load a new web page in the current browser window.
string
getCurrentURL()
Get a string representing the current URL that the browser is looking at.
string
getPageSource()
Get the source of the last loaded page.
string
getTitle()
Get the title of the current page.
string
getWindowHandle()
Return an opaque handle to this window that uniquely identifies it within this driver instance.
array
getWindowHandles()
Get all window handles available to the current session.
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
quit()
Quits this driver, closing every associated window.
mixed
executeScript(string $script, array $arguments = [])
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.
mixed
executeAsyncScript(string $script, array $arguments = [])
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.
You may need to define script timeout using setScriptTimeout()
method of WebDriverTimeouts
first.
string
takeScreenshot(string $save_as = null)
Take a screenshot of the current page.
getStatus()
Status returns information about whether a remote end is in a state in which it can create new sessions.
WebDriverWait
wait(int $timeout_in_second = 30, int $interval_in_millisecond = 250)
Construct a new WebDriverWait by the current WebDriver instance.
Sample usage:
$driver->wait(20, 1000)->until(
WebDriverExpectedCondition::titleIs('WebDriver Page')
);
WebDriverOptions
manage()
An abstraction for managing stuff you would do in a browser menu. For example, adding and deleting cookies.
WebDriverNavigationInterface
navigate()
An abstraction allowing the driver to access the browser's history and to navigate to a given URL.
WebDriverTargetLocator
switchTo()
Switch to a different window or frame.
WebDriverMouse
getMouse()
No description
WebDriverKeyboard
getKeyboard()
No description
RemoteTouchScreen
getTouch()
No description
WebDriverActions
action()
Construct a new action builder.
RemoteWebDriver
setCommandExecutor(WebDriverCommandExecutor $executor)
deprecated
deprecated
internal |
Set the command executor of this RemoteWebdriver
HttpCommandExecutor
getCommandExecutor()
Get the command executor of this RemoteWebdriver
RemoteWebDriver
setSessionID(string $session_id)
deprecated
deprecated
internal |
Set the session id of the RemoteWebDriver.
string
getSessionID()
Get current selenium sessionID
WebDriverCapabilities|null
getCapabilities()
Get capabilities of the RemoteWebDriver.
static array
getAllSessions(string $selenium_server_url = 'http://localhost:4444/wd/hub', int $timeout_in_ms = 30000)
deprecated
deprecated
Returns a list of the currently active sessions.
mixed
execute($command_name, array $params = [])
No description
mixed|null
executeCustomCommand(string $endpointUrl, string $method = 'GET', array $params = [])
Execute custom commands on remote end.
For example vendor-specific commands or other commands not implemented by php-webdriver.
bool
isW3cCompliant()
internal |
No description
static protected RemoteWebDriver
createFromResponse(WebDriverResponse $response, HttpCommandExecutor $commandExecutor)
internal |
Create instance based on response to NEW_SESSION command.
Also detect W3C/OSS dialect and setup the driver/executor accordingly.
protected array
prepareScriptArguments(array $arguments)
Prepare arguments for JavaScript injection
protected RemoteExecuteMethod
getExecuteMethod()
No description
protected RemoteWebElement
newElement(string $id)
Return the WebDriverElement with the given id.
static protected DesiredCapabilities
castToDesiredCapabilitiesObject(array|DesiredCapabilities|null $desired_capabilities = null)
Cast legacy types (array or null) to DesiredCapabilities object. To be removed in future when instance of DesiredCapabilities will be required.
static protected DesiredCapabilities
readExistingCapabilitiesFromSeleniumGrid(string $session_id, HttpCommandExecutor $executor)
No description