getHeader()->hoverMouse(); $this->query('xpath:.//button[contains(@class, "btn-widget-action")]')->waitUntilPresent()->one()->click(true); $menu = CPopupMenuElement::find()->waitUntilVisible()->one(); $aria_label = explode(', ', $menu->getSelected()->getAttribute('aria-label'), 3); return $aria_label[1]; } /** * Get header of widget. * * @return CElement */ public function getHeader() { return $this->query('xpath:.//div[contains(@class, "dashboard-grid-widget-head") or'. ' contains(@class, "dashboard-grid-iterator-head")]/h4')->one(); } /** * Get header text of widget. * * @return string */ public function getHeaderText() { return $this->getHeader()->getText(); } /** * Get content of widget. * * @return CElement */ public function getContent() { return $this->query('xpath:.//div[contains(@class, "dashboard-grid-widget-content") or'. ' contains(@class, "dashboard-grid-iterator-content")]')->one(); } /** * Check if widget is editable (widget edit button is present). * * @return boolean */ public function isEditable() { return $this->query('xpath:.//button[@class="btn-widget-edit"]')->one()->isPresent(); } /** * Get widget configuration form. * * @return CFormElement */ public function edit() { // Edit can sometimes fail so we have to retry this operation. for ($i = 0; $i < 4; $i++) { $this->query('xpath:.//button[@class="btn-widget-edit"]')->waitUntilPresent()->one()->click(true); try { return $this->query('xpath://div[@data-dialogueid="widget_properties"]//form')->waitUntilVisible()->asForm()->one(); } catch (\Exception $e) { if ($i === 1) { throw $e; } } } } /** * @inheritdoc */ public function getReadyCondition() { $target = $this; return function () use ($target) { return ($target->query('xpath:.//div[contains(@class, "is-loading")]')->one(false)->isValid() === false); }; } }