Magento 2 Documentation  2.3
Documentation for Magento 2 CMS v2.3 (December 2018)
WidgetInstanceForm.php
Go to the documentation of this file.
1 <?php
8 
9 use Magento\Mtf\Block\Form;
10 use Magento\Mtf\Client\Locator;
11 use Magento\Mtf\Client\Element\SimpleElement;
12 
16 class WidgetInstanceForm extends Form
17 {
23  protected $chooser = '//*[@class="chooser_container"]//a/img[contains(@alt,"Open Chooser")]';
24 
30  protected $apply = '//*[@class="chooser_container"]//a/img[contains(@alt,"Apply")]';
31 
37  protected $templateBlock = './ancestor::body';
38 
44  protected $header = '.page-header';
45 
51  protected $footer = '.page-footer';
52 
60  public function fillForm(array $layoutFields, SimpleElement $element = null)
61  {
62  $element = $element === null ? $this->_rootElement : $element;
63  $mapping = $this->dataMapping($layoutFields);
64  foreach ($mapping as $key => $values) {
65  $this->_fill([$key => $values], $element);
66  $this->getTemplateBlock()->waitLoader();
67  }
68  }
69 
77  public function getDataOptions(array $fields = null, SimpleElement $element = null)
78  {
79  $element = $element === null ? $this->_rootElement : $element;
80  $mapping = $this->dataMapping($fields);
81  return $this->_getData($mapping, $element);
82  }
83 
89  protected function getTemplateBlock()
90  {
91  return $this->blockFactory->create(
92  \Magento\Backend\Test\Block\Template::class,
93  ['element' => $this->_rootElement->find($this->templateBlock, Locator::SELECTOR_XPATH)]
94  );
95  }
96 
106  protected function clickOnElement(
107  $anchor,
108  $element,
109  $anchorStrategy = Locator::SELECTOR_CSS,
110  $elementStrategy = Locator::SELECTOR_CSS
111  ) {
112  try {
113  $this->browser->find($anchor, $anchorStrategy)->hover();
114  $this->_rootElement->find($element, $elementStrategy)->click();
115  } catch (\PHPUnit_Extensions_Selenium2TestCase_WebDriverException $e) {
116  return false;
117  }
118  return true;
119  }
120 }
$fields
Definition: details.phtml:14
$values
Definition: options.phtml:88
clickOnElement( $anchor, $element, $anchorStrategy=Locator::SELECTOR_CSS, $elementStrategy=Locator::SELECTOR_CSS)
$element
Definition: element.phtml:12