Chrome extensions
Starting from 24.1.0 version BAS supports Chrome extensions. In order to use them only two simple steps are required: install extension and access extension interface. Both steps are easy to accomplish with BAS. Let's review how this can be done.
Installing extension
Extensions may be installed by using “Browser Settings” action. “Extensions” input field inside this action must contain data about extensions that will be used. Each line of this field stores information about a single extension and can have several formats:
- File path to unpacked extension.
- Extension url in chrome web store.
- Extension id.
Further you can read description for each option:
Loading extension from file path
First option requires to store extension on local PC, which may be not very convenient in case if you want to distribute your script. Nevertheless, this option doesn't require any network interaction in order to download extension, so it may be useful to avoid potential network errors.
Using file path for extension storage requires some preparation. Extension must be downloaded and unpacked before usage. It is very important to use ChromeExtensionManager application for unpacking. Other tools available online may not handle it properly. The path specified in the “Extensions” input field must be folder, this folder must contain manifest.json file and this json file must contain “key” key. If these requirements are met, you can use it with “Browser Settings” action. Here is an example:
c:/path/to/extension
For this example c:/path/to/extension/manifest.json must exist.
See “Unpacking extension” section on this page for more details about unpacking.
Loading extension from url
Extension url is line with following pattern:
https://chrome.google.com/webstore/detail/https-everywhere/gcbommkclmclpchllfjekcdonpmejbdp https://chrome.google.com/webstore/detail/online-security-pro/ffjgpapimgnmibnacmeilgjefnoofefp
Extension url can be obtained by visiting Chrome web store. Search for needed extension, than copy and paste url from browser address bar into BAS “Browser Settings” action.
This method is very simple to use, yet it is has complex implementation. Under the hood BAS will download extension to temporary folder, handle caching and multithreading. If you use extension in multiple threads, installation process will be initiated only once.
Loading extension from extension id
Extension id works exactly the same as extension url. Data will still be downloaded to temporary folder. The only difference is the input data format.
Extension id is 32 length string unique among other extensions, examples:
gcbommkclmclpchllfjekcdonpmejbdp ffjgpapimgnmibnacmeilgjefnoofefp
Other information
Several data formats can be mixed with single “Browser Settings” action call, for example:
c:/path/to/extension gcbommkclmclpchllfjekcdonpmejbdp
Subsequent “Browser Settings” action call with extension info will clear previous extension list.
It is very important to understand that setting extension will restart browser process and thereby reset all settings(proxies, headers, etc), so the best place to use this action is thread start.
Extensions are not saved to profile, to system folder and not shared between any browser instances. It means that after old profile is opened again, previously used extensions won't be restored, and you have to set them again with “Browser Settings” action.
Interacting with extension
The are a lot of extensions, which doesn't require any action from user except installation. But most of the them have special interface exposed through popup window. In Chrome browser it can be launched by using following button:
With BAS extension interface can be started with “Click extension button” action. This action will trigger popup in a new BAS tab. You can think of “Click extension button” action as analogue of “Add tab” action but with special extension url. After work with popup will be finished it is recommended to close it with “Close Tab” action.
Popup interface is written in html and therefore can be used and automated just like any other site.
In direct control mode extension page can be triggered through “Extension” menu:
Unpacking extension
Installing extension from file path requires extension unpacking. This can be done with ChromeExtensionManager using following steps:
- Download application using this link.
- Fill “Extension url” field.
- Click on the download button.
- Extension will be saved to folder.
ChromeExtensionManager also provides additional information about extension. For example, settings url and popup url. These url can be loaded in BAS with “Load” or “Add tab” action after extension has been installed.
Note, that unpacking extension is not mandatory, installing it through url is much easier and preferable way.