Пример #1
0
 protected function validateAlertBoxSignifiesCorrectClick(Menu $menu, $parts)
 {
     $instructions = [[WebDriver::INSTRUCTION_MOUSE_MOVETO, '//body']];
     $template = $menu->getBaseXpath();
     $lastXpath = null;
     $parts = explode('/', $parts);
     foreach ($parts as $part) {
         $childXpath = sprintf($menu->getChildXpath(), $part);
         $template .= sprintf('/descendant::%s', $childXpath);
         $instructions[] = [WebDriver::INSTRUCTION_MOUSE_MOVETO, $template];
         $lastXpath = $template;
     }
     array_pop($instructions);
     $instructions[] = [WebDriver::INSTRUCTION_MOUSE_CLICK, $lastXpath];
     $this->getNavigator(InstructionNavigator::NAVIGATOR)->navigateTo($instructions);
     try {
         $this->webdriver->wait(1)->until(ExpectedCondition::alertIsPresent());
         $this->webdriver->switchTo()->alert()->accept();
     } catch (\Exception $e) {
         /* TODO
          *  This is due to an issue with Firefox on Jenkins on Linux where a click is not registered or something.
          * It works without Jenkins, it works on Windows.  But it does not work on Linux, on Jenkins.  Will investigate
          * further, but other things are more pressing.
          *
          */
         $userAgent = $this->webdriver->executeScript('return navigator.userAgent;');
         if (stripos($userAgent, 'firefox') === false) {
             throw $e;
         }
     }
 }