- Notifications
You must be signed in to change notification settings - Fork849
Custom commands
Ondřej Machulda edited this pageApr 16, 2021 ·4 revisions
Since version 1.8.0, php-webdriver allows sending custom commands to the remote end.
This is useful for eg. vendor-specific commands, which are not part of theW3C WebDriver standard and are only available in specific browsers, or for commands which were not yet implemented in this library.
$driver = RemoteWebDriver::create($host,$capabilities);// Execute Mozilla vendor-specific print command$driver->executeCustomCommand('/session/:sessionId/moz/print/','POST');// Execute Mozilla vendor-specific full-page screenshot command$screenshot =$driver->executeCustomCommand('/session/:sessionId/moz/screenshot/full/','POST');file_put_contents('full.png',base64_decode($screenshot));// Execute Appium command to get content of the system clipboard$clipboard =$driver->executeCustomCommand('/session/:sessionId/appium/device/get_clipboard/','POST');// Execute ChromeDevTools protocol command$result =$driver->executeCustomCommand('/session/:sessionId/goog/cdp/execute','POST', ['cmd' =>'Runtime.evaluate','params' => ['expression' =>'window.location.toString()']]);