Download the PHP package akdr/selma without Composer
On this page you can find all versions of the php package akdr/selma. It is possible to download/install these versions without Composer. Possible dependencies are resolved automatically.
Informations about the package selma
Selma
A PHP-Webdriver wrapper trying to simplify the usage of web-scraping.
Usage
To use the wrapper you need to have a Selenium Hub up and running.
To set it up, google or use the docker-compose.yml in the docker directory. Instructions how to start it once you have docker installed is in the file.
Navigation
Navigation handles the browser navigation and manipulation. Its used by the Element class and needs to be started before you try to scrape.
`
Available methods:
Method | Arguments | Comment | Return type |
---|---|---|---|
goTo | String | Make the browser go to the page in first argument. | Navigation |
currentUrl | none | Returns the current URL as a string. | String |
javascript | String | Executes javascript in the browser and returns it output. | ?String |
scrollTo | ?Int | Scrolls the page to the first arguments X-value. If omitted is scrolls to the bottom. | Navigation |
screenshot | String | Takes a screenshot of the page and saves it to the absolute path from the first argument. | Navigation |
getSource | none | Returns the source from the current URL as a string. | String |
cli | String | Prints a message in the error-log | Navigation |
Element
The Element class handles everything DOM-related. It searches for DOM-elements, extracts text, filling in inputs and clicking elements.
Available methods
To get an Element and manipulate it, you can either use the construct or the set() method. They both takes an array as argument and is executed in the order being presented. The selector key has to be set and always (with the exception of 'element') be first.
Key | Value-type | Comment |
---|---|---|
element | Facebook\WebDriver\ Remote\RemoteWebElement | If you need to find a multiple elements and their offspring, you can inject a RemoteWebElement and find its children through 'selector' |
selector | String | Gets the first matching selector with the matching CSS-selector. If the key 'element' is set, it will search inside that Element. |
attribute | String | Gets the attribute of the 'selector'. 'text' for the text, 'href' for the link and so on. |
click | Bool | If true, the browser will try and click the 'selector' element. |
class | String | Sets the property $hasClass to true if the 'selector' element has the CSS-class, else false. |
input | String | Prints the argument into the 'selector' element. |
pressKey | String | Presses the button passed in the argument, uses constants found here |
delay | Int | Makes the browser sleep for the amount of milliseconds in the argument |
waitForElement | Int | Waits for an element to appear in the browser. The argument sets amount of 0.01 seconds delays it is going to wait. |
To get the value from attribute, chain ->getValue('int'|'float'|null) on to the construct or set().
Public properties
If you need to retrieve the RemoteWebElement, call for the property inside the class named 'element'.
If you need to retrieve the class-bool, call for the property 'hasClass'.
Example:
All versions of selma with dependencies
jbzoo/utils Version 5.*
php Version >=8.0
jbzoo/data Version 5.*
ext-json Version *