Web Driver Replacement in the Functional Testing Framework
Overview
The Functional Testing Framework (FTF) enables you to change a web driver library used for communication with Selenium Server, PhantomJS or any other web page automation tool.
Web drivers provided with the FTF are the following:
Both implement the DriverInterface.php
interface. The interface declares methods that are used in web page automation such as click()
, isVisible()
, setValue()
, dragAndDrop()
etc.
To use a custom web driver, you must implement the DriverInterface.php
interface.
Use provided in the FTF web drivers as examples.
Set up the Facebook web driver
To set up the Facebook web driver, use the following steps:
- In
<magento2_root_dir>/dev/tests/functional/etc/di.xml
, add the<preference for="Magento\Mtf\Client\DriverInterface" type="Magento\Mtf\Client\Driver\Facebook\Driver" />
element. - In
<magento2_root_dir>/dev/tests/functional/composer.json
, move the"facebook/webdriver": "dev-master"
entry from the"suggest"
list to the"require"
list. - Run in your terminal:
1
cd <magento2_root_dir>/dev/tests/functional
1
composer update
You still need to run the Selenium Server in order to run the tests, because at this point the test run procedure is not yet changed.
Add and setup a custom web driver
To add a custom web driver, you must implement the DriverInterface.php
interface.
- Create the
<magento2_root_dir>/dev/tests/functional/lib/Magento/Mtf/Client/Driver/<Your_driver>
directory. - In the directory, create the
Driver.php
class which implementsDriverInterface.php
.
To setup the custom web driver, follow:
- In
<magento2_root_dir>/dev/tests/functional/etc/di.xml
, add the<preference for="Magento\Mtf\Client\DriverInterface" type="Magento\Mtf\Client\Driver\<Your_driver>\Driver" />
element. - In
<magento2_root_dir>/dev/tests/functional/composer.json
, add corresponding entry to the"require"
list (if related module is available on Packagist). And run in your terminal:
1
cd <magento2_root_dir>/dev/tests/functional
1
composer update
You still need to run the Selenium Server in order to run the tests, because at this point the test run procedure is not yet changed.