Posted on

Magento 2: How to test a simple product page with Magento Functional Testing Framework?

I have attempted to use “StorefrontOnlyXProductLeftForSimpleProductsTest” from within magento-catalog/Test/Mftf/test but results in error:

Modules: MagentoFunctionalTestingFrameworkModuleMagentoWebDriver, MagentoFunctionalTestingFrameworkModuleMagentoSequence, MagentoFunctionalTestingFrameworkModuleMagentoAssert, MagentoFunctionalTestingFrameworkModuleMagentoActionProxies, Asserts, MagentoFunctionalTestingFrameworkHelperHelperContainer
——————————————————————————–
CustomCheckTestCest: Custom check test
Signature: MagentoAcceptanceTest_defaultBackendCustomCheckTestCest:CustomCheckTest
Test: tests/functional/Magento/_generated/default/CustomCheckTestCest.php:CustomCheckTest
Scenario —
[createCategory] create entity “createCategory”,”hook”,”_defaultCategory”,[],[]
[createProduct] create entity “createProduct”,”hook”,”ApiSimpleProduct”,[“createCategory”],[]
[setStockThresholdQty] magento cli “config:set cataloginventory/options/stock_threshold_qty 10000″,60
<!doctype html>
<html lang=”en”>
<head >
<script>
var BASE_URL = ‘httpu003Au002Fu002Fdomain.comu003A24882u002Fmageu002Fpubu002
[flushCache] magento cli “cache:flush config”,60
<!doctype html>
<html lang=”en”>
<head >
<script>
var BASE_URL = ‘httpu003Au002Fu002Fdomain.comu003A24882u002Fmageu002Fpubu002
<amOnPage url=”{{StorefrontCategoryPage.url($createPreReqCategory.name$)}}” stepKey=”navigateToCategoryPage”/>
[openProductPage] StorefrontOpenProductPageActionGroup
[openProductPage] am on page “/.html”
[waitForProductPageLoaded] wait for page load 59
[seeOnlyLeftBlock] see element “//div[@class=’product-info-price’]//div[@class=’product-info-stock-sku’]//div[@class=’availability only’]”
[saveScreenshot] save screenshot
[deleteCategory] delete entity “createCategory”,”hook”
ERROR

——————————————————————————–

Time: 04:31.907, Memory: 40.00 MB

There was 1 error:

———
1) CustomCheckTestCest: Custom check test
Test tests/functional/Magento/_generated/default/CustomCheckTestCest.php:CustomCheckTest

[MagentoFunctionalTestingFrameworkExceptionsTestFrameworkException] Error HTTP response code: 400 Response:{“message”:”The “{id}” value’s type is invalid. The “int” type was expected. Verify and try again.”,”trace”:null}

Scenario Steps:

15. $I->deleteEntity(“createCategory”,”hook”) at tests/functional/Magento/_generated/default/CustomCheckTestCest.php:42
14. $I->saveScreenshot() at tests/functional/Magento/_generated/default/CustomCheckTestCest.php:54
13. $I->seeElement(“//div[@class=’product-info-price’]//div[@class=’produc…”) at tests/functional/Magento/_generated/default/CustomCheckTestCest.php:73
12. // Exiting Action Group [openProductPage] StorefrontOpenProductPageActionGroup
11. $I->waitForPageLoad(59) at tests/functional/Magento/_generated/default/CustomCheckTestCest.php:71
10. $I->amOnPage(“/.html”) at tests/functional/Magento/_generated/default/CustomCheckTestCest.php:70

#1 /var/www/html/mage/vendor/magento/magento2-functional-testing-framework/src/Magento/FunctionalTestingFramework/DataTransport/Protocol/CurlTransport.php:179
#2 /var/www/html/mage/vendor/magento/magento2-functional-testing-framework/src/Magento/FunctionalTestingFramework/DataTransport/WebApiExecutor.php:103
#3 /var/www/html/mage/vendor/magento/magento2-functional-testing-framework/src/Magento/FunctionalTestingFramework/DataGenerator/Persist/CurlHandler.php:172
#4 /var/www/html/mage/vendor/magento/magento2-functional-testing-framework/src/Magento/FunctionalTestingFramework/DataGenerator/Persist/DataPersistenceHandler.php:156
#5 /var/www/html/mage/vendor/magento/magento2-functional-testing-framework/src/Magento/FunctionalTestingFramework/DataGenerator/Handlers/PersistedObjectHandler.php:146
#6 /var/www/html/mage/vendor/magento/magento2-functional-testing-framework/src/Magento/FunctionalTestingFramework/Module/MagentoActionProxies.php:103
#7 MagentoFunctionalTestingFrameworkModuleMagentoActionProxies->deleteEntity
#8 /var/www/html/mage/vendor/magento/magento2-functional-testing-framework/src/Magento/FunctionalTestingFramework/_generated/AcceptanceTesterActions.php:3578
#9 /var/www/html/mage/dev/tests/acceptance/tests/functional/Magento/_generated/default/CustomCheckTestCest.php:42
#10 MagentoAcceptanceTest_defaultBackendCustomCheckTestCest->_after

ERRORS!
Tests: 1, Assertions: 1, Errors: 1.

—Could this be the issue(if so, how to fix it?)—-

[openProductPage] am on page “/.html”

——————–

<!–
/**
* Copyright © Magento, Inc. All rights reserved.
* See COPYING.txt for license details.
*/
–>

<tests xmlns:xsi=”http://www.w3.org/2001/XMLSchema-instance”
xsi:noNamespaceSchemaLocation=”urn:magento:mftf:Test/etc/testSchema.xsd”>
<test name=”CustomCheckTest”>
<annotations>
<features value=”Catalog”/>
<title value=”See Only * Left block”/>
<stories value=”See Only * Left on product page if Only X left Threshold was set”/>
<description value=”See Only * Left on product page if Only X left Threshold was set”/>
<testCaseId value=”MC-35235″/>
<severity value=”MINOR”/>
</annotations>
<before>
<createData entity=”_defaultCategory” stepKey=”createCategory”/>
<createData entity=”ApiSimpleProduct” stepKey=”createProduct”>
<requiredEntity createDataKey=”createCategory”/>
</createData>
<magentoCLI command=”config:set {{CatalogInventoryOptionsOnlyXleftThreshold.path}} 10000″ stepKey=”setStockThresholdQty”/>
<magentoCLI command=”cache:flush config” stepKey=”flushCache”/>
</before>
<after>
<deleteData createDataKey=”createCategory” stepKey=”deleteCategory”/>
<deleteData createDataKey=”createProduct” stepKey=”deleteProduct”/>
<magentoCLI command=”config:set {{CatalogInventoryOptionsOnlyXleftThreshold.path}} {{CatalogInventoryOptionsOnlyXleftThreshold.value}}” stepKey=”removedStockThresholdQty”/>
</after>
<actionGroup ref=”StorefrontOpenProductPageActionGroup” stepKey=”openProductPage”>
<argument name=”productUrl” value=”$createProduct.custom_attributes[url_key]$”/>
</actionGroup>
<seeElement selector=”{{StorefrontProductPageSection.onlyProductsLeft}}” stepKey=”seeOnlyLeftBlock”/>
</test>
</tests>

Leave a Reply

Your email address will not be published. Required fields are marked *