Magento 2 Documentation  2.3
Documentation for Magento 2 CMS v2.3 (December 2018)
NewCategoryIds.php
Go to the documentation of this file.
1 <?php
8 
10 use Magento\Mtf\Block\Form;
11 
15 class NewCategoryIds extends Form
16 {
22  protected $buttonNewCategory = '[data-index="create_category_button"]';
23 
29  protected $createCategoryModal = '.product_form_product_form_create_category_modal';
30 
36  protected $createCategoryButton = '#save';
37 
44  public function addNewCategory(Category $category)
45  {
46  $data = [
47  'name' => $category->getName(),
48  'parent_category' => $category->getDataFieldConfig('parent_id')['source']->getParentCategory()->getName()
49  ];
50 
51  $this->openNewCategoryDialog();
52  $this->_fill($this->dataMapping($data));
53 
54  $this->_rootElement->find($this->createCategoryButton)->click();
55  $this->waitForElementNotVisible($this->createCategoryButton);
56  }
57 
63  protected function openNewCategoryDialog()
64  {
65  $this->browser->find($this->buttonNewCategory)->click();
66  $this->waitForElementVisible($this->createCategoryModal);
67  }
68 }