PHP code example of edmondscommerce / behat-html-context

1. Go to this page and download the library: Download edmondscommerce/behat-html-context 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/ */

    

edmondscommerce / behat-html-context example snippets



// Instantiate context class, 
$args = [
    'args' => [
        '--disable-gpu',
        '--window-size=1920,1080',
        '--start-maximised',
    ],
];

$driver = new Selenium2Driver('chrome', $args);
$session = new Behat\Mink\Session($driver);
$mink = new Mink(['selenium2' => $session]);

$htmlContext = new HTMLContext();
$htmlContext->setMink($mink);

//Find a node and return it or throw an exception
$htmlContext->findOneOrFail($selector, $locator, $message = null)

//Find multiple nodes and return an array of them or throw an exception if none are found
$htmlContext->findAllOrFail($selector, $locator, $message = null)

//Same as findOrFail but searches from the context of another node, can be useful for chaining
$htmlContext->findOrFailFromNode(\Behat\Mink\Element\NodeElement $element, $selector, $locator, $message = null)