Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
custom theme example
In order to run test on any custom theme first of all you need to update all changed blocks according to new flow. To do this you need
1) create separate theme folder dev/tests/functional/tests/theme/responsive
2) create block that has another behavior then in default theme dev/tests/functional/tests/theme/responsive/Mage/Catalog/Test/Block/Search.php
3) update files autoload in composer.json
"autoload": {
"psr-4": {
"Magento\\": ["lib/Magento/", "vendor/magento/mtf/Magento/", "testsuites/Magento/"],
"Mage\\": ["generated/Mage/", "tests/theme/responsive/Mage/", "tests/app/Mage/"],
"Enterprise\\": ["generated/Community/", "tests/app/Community/"],
"Local\\": ["generated/Local/", "tests/app/Local/"],
"Test\\": "generated/Test/"
}
}
4) regenerate autoload running command ‘composer dump-autoload’
5) run test.
For setting window size our test environment is responsible, but if you want to run locally on different windows size you need:
1) add new parameter settings to MTF configuration file dev/tests/functional/etc/config.xml
<server>
<item name="selenium">
<desiredCapabilities>
<width>400</width>
<height>400</height>
</desiredCapabilities>
</item>
</server>
2) make changes in dev/tests/functional/lib/Magento/Mtf/Client/Driver/Selenium/Driver.php
protected function init()
{
$this->driver = $this->remoteDriverFactory->create();
$this->driver->setBrowserUrl('about:blank');
$params = $this->configuration->get('server/selenium');
$this->driver->setupSpecificBrowser($params);
$this->driver->prepareSession();
$this->setWindowSize($params);
$this->driver->cookie()->clear();
$this->driver->refresh();
}
/**
* Set browser window size.
*
* @param array $params
* @return void
*/
protected function setWindowSize(array $params)
{
$windowSize = [];
if (isset($params['desiredCapabilities']['width'])) {
$windowSize['width'] = (int)$params['desiredCapabilities']['width'];
}
if (isset($params['desiredCapabilities']['height'])) {
$windowSize['height'] = (int)$params['desiredCapabilities']['height'];
}
if (empty($windowSize)) {
$this->driver->currentWindow()->maximize();
} else {
$this->driver->currentWindow()->size($windowSize);
}
}
3) run test.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.