PHP code example of mariopenterman / php-webdriver

1. Go to this page and download the library: Download mariopenterman/php-webdriver library. Choose the download type require.

2. Extract the ZIP file and open the index.php.

3. Add this code to the index.php.
    
        
<?php
require_once('vendor/autoload.php');

/* Start to develop here. Best regards https://php-download.com/ */

    

mariopenterman / php-webdriver example snippets


// Chromedriver (if started using --port=4444 as above)
$host = 'http://localhost:4444';
// Geckodriver
$host = 'http://localhost:4444';
// selenium-server-standalone-#.jar (version 2.x or 3.x)
$host = 'http://localhost:4444/wd/hub';
// selenium-server-standalone-#.jar (version 4.x)
$host = 'http://localhost:4444';

use Facebook\WebDriver\Remote\RemoteWebDriver;

// Chrome
$driver = RemoteWebDriver::create($host, DesiredCapabilities::chrome());
// Firefox
$driver = RemoteWebDriver::create($host, DesiredCapabilities::firefox());
// Microsoft Edge
$driver = RemoteWebDriver::create($host, DesiredCapabilities::microsoftEdge());

use Facebook\WebDriver\Remote\DesiredCapabilities;

$desiredCapabilities = DesiredCapabilities::firefox();

// Disable accepting SSL certificates
$desiredCapabilities->setCapability('acceptSslCerts', false);

// Run headless firefox
$desiredCapabilities->setCapability('moz:firefoxOptions', ['args' => ['-headless']]);

$driver = RemoteWebDriver::create($host, $desiredCapabilities);