1. Go to this page and download the library: Download akdr/selma 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/ */
akdr / selma example snippets
// Example of starting a navigation. The first argument is the location of Selenium Hub and
// the second is Chrome-options.
use ComparicoAB\Selma\Navigation;
$nav = new Navigation('http://localhost:4444/wd/hub', ["window-size=1920,4000", "--headless", "--disable-gpu", "--no-sandbox"]);
// Example of using the Element to fill out a form and then clicking the submit button.
use Akdr\Selma\Element;
use Akdr\Selma\Navigation;
$nav = new Navigation('http://localhost:4444/wd/hub', ["window-size=1920,4000", "--headless", "--disable-gpu", "--no-sandbox"]);
// First time we need to initiate the Element to use our browser,
// later we can keep using it with the method Set.
// Enter the text "Selma is being used" into the input.
$element = new Element($nav, [
'selector' => '#form-input',
'input' => "Selma is being used"
]);
// Click the submit button
$element->set([
'selector' => '#submit-button',
'click' => true,
'delay' => 400000
]);
//Select the response, which is a span without a class or id inside a container.
$container = $element->set([
'selector' => '.container'
]);
$response = $element->set([
'element' => $container->element,
'selector' => 'span',
'attribute' => 'text'
]);
// Finally, read the response and get the integer while removing the rest of the text.
$response->getValue('int');
use ComparicoAB\Selma\Navigation;
use ComparicoAB\Selma\Element;
// Setup the browser and initiate the element class.
$nav = new Navigation('http://localhost:4444/wd/hub', ["window-size=1920,4000", "--headless", "--disable-gpu", "--no-sandbox"]);
$element = new Element($nav, []);
// <a href="https://comparico.se class="title">Title Number 3.14</a>
$title = $element->set([
'selector' => 'a',
'hasClass' => 'title',
'attribute' => 'href'
]);
// Returns the RemoteWebElement
$title->element; // Facebook\WebDriver\Remote\RemoteWebElement
// Returns the class-bool
$title->hasClass; // true
// Fetch the attribute
$title->getValue(); // Title Number 3.14
$title->getValue('int'); // 314
$title->getValue('float'); // 3.14
Loading please wait ...
Before you can download the PHP files, the dependencies should be resolved. This can take some minutes. Please be patient.