_objectManager->create(\Magento\Catalog\Api\ProductRepositoryInterface::class); $product = $productRepository->get('bundle-product'); $this->dispatch('catalog/product/view/id/' . $product->getEntityId()); $responseBody = $this->getResponse()->getBody(); $this->assertContains('Bundle Product', $responseBody); $this->assertContains( 'In stock', $responseBody, 'Bundle Product Detailed Page does not contain In Stock field' ); $addToCartCount = substr_count($responseBody, 'Add to Cart'); $this->assertEquals(1, $addToCartCount, '"Add to Cart" button should appear on the page exactly once.'); $actualLinkCount = substr_count($responseBody, '>Bundle Product Items<'); $this->assertEquals(1, $actualLinkCount, 'Bundle product options should appear on the page exactly once.'); $this->assertNotContains('class="options-container-big"', $responseBody); $this->assertEquals( 1, \Magento\TestFramework\Helper\Xpath::getElementsCountForXpath( '//*[@id="product-options-wrapper"]', $responseBody ) ); } }