group | title |
---|---|
functional-testing-framework-guide |
Web Driver Replacement in the Functional Testing Framework |
The Functional Testing Framework (FTF) enables you to change a web driver {% glossarytooltip 08968dbb-2eeb-45c7-ae95-ffca228a7575 %}library{% endglossarytooltip %} 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.
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:
cd <magento2_root_dir>/dev/tests/functional
composer update
{: .bs-callout .bs-callout-info } You still need to [run the Selenium Server]({{ page.baseurl }}/mtf/mtf_quickstart/mtf_quickstart_environment.html#mtf_quickstart_env_selenium) in order to run the tests, because at this point the test run procedure is not yet changed.
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:
cd <magento2_root_dir>/dev/tests/functional
composer update
{: .bs-callout .bs-callout-info } You still need to [run the Selenium Server]({{ page.baseurl }}/mtf/mtf_quickstart/mtf_quickstart_environment.html#mtf_quickstart_env_selenium) in order to run the tests, because at this point the test run procedure is not yet changed.