Ejemplo n.º 1
0
 /**
  * Check is visible widget selector.
  *
  * @param Widget $widget
  * @param string $pageName
  * @return array
  * @throws \Exception
  */
 public function isWidgetVisible(Widget $widget, $pageName)
 {
     $error = [];
     $widgetType = $widget->getWidgetOptions()['type_id'];
     if ($this->hasRender($widgetType)) {
         return $this->callRender($widgetType, 'isWidgetVisible', ['widget' => $widget, 'pageName' => $pageName]);
     } else {
         if (isset($this->widgetSelectors[$widgetType])) {
             $widgetOptions = $widget->getWidgetOptions();
             unset($widgetOptions['type_id']);
             foreach ($widgetOptions as $widgetOption) {
                 foreach ($widgetOption['entities'] as $entity) {
                     $widgetText = $entity->getStoreContents()['store_content'];
                     $isWidgetVisible = $this->_rootElement->find(sprintf($this->widgetSelectors[$widgetType], $widgetText), Locator::SELECTOR_XPATH)->isVisible();
                     if (!$isWidgetVisible) {
                         $error[] = "Widget with title {$widget->getTitle()} is absent on {$pageName}  page.";
                     }
                 }
             }
             return $error;
         } else {
             throw new \Exception('Determine how to find the widget on the page.');
         }
     }
 }
 /**
  * Assert widget availability in widget grid.
  *
  * @param Widget $widget
  * @param WidgetInstanceIndex $widgetInstanceIndex
  * @return void
  */
 public function processAssert(Widget $widget, WidgetInstanceIndex $widgetInstanceIndex)
 {
     $widgetInstanceIndex->open();
     $widgetTitle = $widget->getTitle();
     \PHPUnit_Framework_Assert::assertTrue($widgetInstanceIndex->getWidgetGrid()->isRowVisible(['title' => $widgetTitle]), "Widget with title {$widgetTitle} is absent in Widget grid.");
 }
Ejemplo n.º 3
0
 /**
  * Check is visible widget selector.
  *
  * @param Widget $widget
  * @param string $pageName
  * @param string $widgetType
  * @param string $widgetText
  * @return string|null
  */
 protected function isWidgetVisible(Widget $widget, $pageName, $widgetType, $widgetText)
 {
     $widgetSelector = sprintf($this->widgetSelectors[$widgetType], $widgetText);
     return $this->_rootElement->find($widgetSelector, Locator::SELECTOR_XPATH)->isVisible() ? null : "Widget with title {$widget->getTitle()} is absent on {$pageName}  page.";
 }