getMenu()->waitUntilReady()->fill($item); } return $this; } /** * Get popup menu. * * @return CPopupMenuElement */ public function getMenu() { $query = $this->query('xpath://ul[contains(@class, "menu-popup-top")]')->asPopupMenu(); $menu = $query->one(false); if ($menu->isValid()) { return $menu; } // Sometimes menu is not summoning from the first time. for ($i = 0; $i < 2; $i++) { try { $this->click(true); $menu = $query->waitUntilVisible()->one(false); if ($menu->isValid()) { return $menu; } } catch (Exception $e) { sleep(1); // Code is not missing here. } } throw new Exception('Failed to wait for menu to be visible!'); } /** * @inheritdoc */ public function fill($text) { return $this->select($text); } }