Download the PHP package aklump/dom-testing-selectors without Composer

On this page you can find all versions of the php package aklump/dom-testing-selectors. 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 dom-testing-selectors

DOM Testing Selectors

Packagist link

This library offers a PHP solution designed to add specific markup to your DOM for testing purposes. By default, it configures a data-test attribute for DOM elements, as shown in the examples. The library is intended to be integrated into a server-side rendering pipeline, which generates your markup.

This attribute should be used exclusively for targeting elements in your tests. Separating concerns in this way helps prevent test fragility that can arise from relying on classes or other multipurpose attributes that you may not control and could change unexpectedly. By using a dedicated data attribute for testing—one that you control—you can ensure that your tests remain stable and reliable over time.

Install with Composer

  1. Require this package:

Selectors

You may also add a group to the selectors, which will prefix the attribute value:

Naming Convention

Be aware that in an effort to reduce confusion and errors, the provided \AKlump\DomTestingSelectors\Selector\AbstractSelector has an opinion about naming convention.

To change this behavior you should create a custom selector class, overriding \AKlump\DomTestingSelectors\Selector\AbstractSelector::applyNamingConventions.

Using a Custom Attribute

This example will illustrate how to change the attribute to data-cy, which you may want to use while testing with Cypress. Simple create a custom selector class and use in place of DataTestSelector.

To learn more about selectors, refer to \AKlump\DomTestingSelectors\Selectors\AbstractSelector.

Using Classes as Testing Selectors

The included \AKlump\DomTestingSelectors\Selector\ClassSelector can be used instead of \AKlump\DomTestingSelectors\Selector\DataTestSelector if you want to use CSS classes (e.g. t-foo) for selecting your elements. Notice the naming convention is altered for classes, using hyphens instead of underscores.

Handlers

Handlers do the work of adding the selector markup to your HTML. The \AKlump\DomTestingSelectors\Handlers\StringHandler is provided by this library, to add the selector to HTML strings.

Framework-specific and custom handlers are very easy to add by implementing \AKlump\DomTestingSelectors\Handler\HandlerInterface.

Factories

In practice you may have multiple handlers to cover the full range of elements you wish to markup. This is the reason for \AKlump\DomTestingSelectors\AbstractHandlerFactory. The following example shows how you would write and use a custom factory.

Make it a Safe Factory

Notice that you have to catch if a handler cannot be found for a given element. To get around this you may want to create a "safe factory", that is one which adds as it's final handler the \AKlump\DomTestingSelectors\Handler\PassThroughHandler or something similar (maybe with your own logging). Instead of an exception, the $element will simply pass through unchanged.


All versions of dom-testing-selectors with dependencies

PHP Build Version
Package Version
Requires php Version >=7.3
ext-dom Version *
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 aklump/dom-testing-selectors contains the following files

Loading the files please wait ....