Magento 2 Documentation  2.3
Documentation for Magento 2 CMS v2.3 (December 2018)
VideoDialog.php
Go to the documentation of this file.
1 <?php
8 
9 use Magento\Mtf\Block\Form;
10 use Magento\Mtf\Client\Locator;
11 
15 class VideoDialog extends Form
16 {
22  protected $saveButton = '.video-create-button';
23 
29  protected $editButton = '.video-edit';
30 
36  protected $deleteButton = '.video-delete-button';
37 
43  protected $getVideoButton = '#new_video_get';
44 
50  protected $screenshotPreview = '#new_video_screenshot_preview + img';
51 
57  private $videoPlayer = '#new-video div.video-player-container';
58 
64  protected $closeButton = '.action-close';
65 
71  public function clickSaveButton()
72  {
73  $this->_rootElement->find($this->saveButton)->click();
74  return $this;
75  }
76 
82  public function clickEditButton()
83  {
84  $this->waitForElementNotDisabled($this->editButton);
85  $this->_rootElement->find($this->editButton)->click();
86  return $this;
87  }
88 
94  public function clickDeleteButton()
95  {
96  $this->_rootElement->find($this->deleteButton)->click();
97  return $this;
98  }
99 
105  public function clickCloseButton()
106  {
107  $this->_rootElement->find($this->closeButton)->click();
108  return $this;
109  }
110 
118  public function fillForm(array $data)
119  {
120  $data = $this->dataMapping($data);
121  if (isset($data['video_url'])) {
122  $videoFill = ['video_url' => $data['video_url']];
123  unset($data['video_url']);
124  $this->_fill($videoFill);
125  $this->_rootElement->find($this->getVideoButton)->click();
126  $this->waitForElementVisible($this->screenshotPreview);
127  $this->waitForElementVisible($this->videoPlayer);
128  }
129  $this->_fill($data);
130  return $this;
131  }
132 
140  public function waitForElementNotDisabled($selector, $strategy = Locator::SELECTOR_CSS)
141  {
142  $browser = $this->browser;
143  return $browser->waitUntil(
144  function () use ($browser, $selector, $strategy) {
145  $element = $browser->find($selector, $strategy);
146  return $element->isDisabled() == false ? true : null;
147  }
148  );
149  }
150 
156  public function getVideoInfo()
157  {
158  $data = [];
159  foreach (array_keys($this->mapping) as $field) {
160  $data[$field] = $this->_rootElement->find($field, Locator::SELECTOR_NAME)->getValue();
161  }
162  return $data;
163  }
164 
171  public function validate(array $video)
172  {
173  $result = true;
174  $data = $this->getVideoInfo();
175  foreach ($video as $key => $value) {
176  if ($value != $data[$key]) {
177  $result = false;
178  break;
179  }
180  }
181  return $result;
182  }
183 }
$value
Definition: gender.phtml:16
$element
Definition: element.phtml:12