Download the PHP package timatanga/headless without Composer

On this page you can find all versions of the php package timatanga/headless. It is possible to download/install these versions without Composer. Possible dependencies are resolved automatically.

FAQ

After the download, you have to make one include require_once('vendor/autoload.php');. After that you have to import the classes with use statements.

Example:
If you use only one package a project is not needed. But if you use more then one package, without a project it is not possible to import the classes with use statements.

In general, it is recommended to use always a project to download your libraries. In an application normally there is more than one library needed.
Some PHP packages are not free to download and because of that hosted in private repositories. In this case some credentials are needed to access such packages. Please use the auth.json textarea to insert credentials, if a package is coming from a private repository. You can look here for more information.

  • Some hosting areas are not accessible by a terminal or SSH. Then it is not possible to use Composer.
  • To use Composer is sometimes complicated. Especially for beginners.
  • Composer needs much resources. Sometimes they are not available on a simple webspace.
  • If you are using private repositories you don't need to share your credentials. You can set up everything on our site and then you provide a simple download link to your team member.
  • Simplify your Composer build process. Use our own command line tool to download the vendor folder as binary. This makes your build process faster and you don't need to expose your credentials for private repositories.
Please rate this library. Is it a good library?

Informations about the package headless

Headless

This package provides a fluent interface for browser automation. It is heavily influenced by Laravel Dusk so all credits go to Taylor Otwell and his amazing team for there incredible work and inspiration! Instead of installing JDK or Selenium, this package requires and uses a standalone ChromeDriver.

Installation

To get started, you should install Google Chrome on your system. Google Chrome will be managed in headless mode via this package through the ChromeDriver.

Please make use of composer to install this package

composer require dbisapps/headless

Instead of relying on Laravel's artisan command line interface to install the ChromeDriver this package supports a static method to get the driver installed within the package directory:

use dbizapps\Headless\Browser;

$result = Browser::install();

The required ChromeDriver version is detected based on the major version of the installed Chrome/Chromium browser on your machine.

Browser Navigation

The Headless packages provides an easy to use, fluent interface to concat browser operations. Navigation operations all return the browser instance itself.

A good starting point is to visit a page by:

use dbizapps\Headless\Browser;

$browser = new Browser;

$browser->visit('laravel.com');

Other available navigation operations are:

// browse to the blank page.
$browser->blank();

// refresh the page
$browser->refresh();

// navigate back
$browser->back();

// navigate back
$browser->forward();

Browser Sizing & Moving

Even in headless mode with non-visible operations, it is sometimes useful for further operations to adjust the browser size

// maximize browser window
$browser->maximize();

// resize browser window
$browser->resize($width, $height);

// make the browser window as large as the content.
$browser->fitContent();

// Move the browser window.
$browser->move($x, $y);

Page

Just visiting a page isn't that useful. A useful browser automation needs to interact with page elements.

Interacting with page form elements is enabled after visiting a page

// Click on link with the given selector, e.g. #submit
$browser->click($selector);

// Press on button with the given selector
$browser->press($selector);

// Get (just passing the selector) or set value (passing selector and value) of element with the given selector. 
$browser->value($selector, $value);

// Get text of element with the given selector
$browser->text($selector);

// Clear selected element and type value
$browser->type($selector, $value);

// Append value to element with given selector
$browser->append($selector, $value);

// Clear the given field
$browser->clear($selector);

// Select the given value of element with given selector
$browser->select($selector, $value);

// Select radio option
$browser->radio($selector, $value);

// Check the given checkbox.
$browser->check($selector, $value);

// Uncheck the given checkbox.
$browser->uncheck($selector, $value);

Dialog interactions are supported as well

// Accept a JavaScript dialog.
$browser->acceptDialog();

// DismissDialog a JavaScript dialog.
$browser->dismissDialog();

// Type the given value in an open JavaScript prompt dialog.
$browser->typeInDialog($value);

Execute Scripts

If you need to extend existing scripts with custom javascripts just use:

// Execute JavaScript within the browser.
$browser->script($script);

Assertions

For automated browser interactions you may want to assert that a specific content is on the page.

// Assert that the page title matches the given text.
$browser->assertTitle($title);

// Assert that the page title contains the given text.
$browser->assertTitleContains($text);

// Assert that the given text is present on the page.
$browser->assertSee($text);

// Assert that the given text is not present on the page.
$browser->assertDontSee($text);

// Assert that the given text is present within the selector.
$browser->assertSeeIn($selector, $value);

// Assert that the given text is not present within the selector.
$browser->assertDontSeeIn($selector, $value);

// Assert that the given link is present on the page.
$browser->assertSeeLink($link);

// Assert that the given link is not present on the page.
$browser->assertDontSeeLink($link);

// Assert that the given input field does not have the given value.
$browser->assertInputValue($field, $value);

// Assert that the given input field does not have the given value.
$browser->assertInputValueIsNot($field, $value);

// Assert that the given checkbox is checked.
$browser->assertChecked($field, $value);

// Assert that the given checkbox is not checked.
$browser->assertNotChecked($field, $value);

// Assert that the given radio field is selected.
$browser->assertRadioSelected($field, $value);

// Assert that the given radio field is not selected.
$browser->assertRadioNotSelected($field, $value);

// Assert that the given dropdown has the given value selected.
$browser->assertSelected($field, $value);    

// Assert that the given dropdown does not have the given value selected.
$browser->assertNotSelected($field, $value);   

// Assert that the given array of values are available to be selected.
$browser->assertSelectHasOptions($field, $values); 

// Assert that the given array of values are not available to be selected.
$browser->assertSelectMissingOptions($field, $values); 

... and many more. Please refer to the SupportAssertions Trait for details.

Get Messages, Content or Outputs

Headless browser operations require feedback to be useful at any kind. From computed messages, console logs to page source or page caputures are numerous browser operations available:

// Preserve computed or returned messages
$arr = $browser->getMessages()

// set html source into browser
$page = $browser->setHtml($html)  

// returns html page dump 
$page = $browser->getPage()

// dump html page to disk
$path = $browser->savePage($filename)

// takes a screen capture, stores as image
$path = $browser->screenshot($filename)

// takes a screen (visible screen) capture, stores as image
$path = $browser->screenshot($filename)

// takes a page (viewport) capture, stores as image
$path = $browser->pageshot($filename)

// dumps the console log to disk
$path = $browser->consoleLog($filename)

All versions of headless with dependencies

PHP Build Version
Package Version
Requires php Version ^8.0
ext-json Version *
ext-zip Version ^1.19
symfony/finder Version 6.0.x-dev
symfony/process Version ^4.3|^5.0
php-webdriver/webdriver Version ^1.9.0
Composer command for our command line client (download client) This client runs in each environment. You don't need a specific PHP version etc. The first 20 API calls are free. Standard composer command

The package timatanga/headless contains the following files

Loading the files please wait ....