Ejemplo n.º 1
0
 /**
  * Initialize basic component system
  */
 public static function init()
 {
     define('MENTA_ROOTDIR', dirname(__FILE__));
     // Provide configuration object to all components
     Menta_Events::addObserver('before_component_get', function (Menta_Component_Abstract $component) {
         // set configuration to each component
         $component->setConfiguration(Menta_ConfigurationPhpUnitVars::getInstance());
         // pass current test to components inheriting from Menta_Component_AbstractTest
         if ($component instanceof Menta_Component_AbstractTest && isset($GLOBALS['current_testcase']) && $GLOBALS['current_testcase'] instanceof PHPUnit_Framework_TestCase) {
             /* @var $component Menta_Component_AbstractTest */
             $component->setTest($GLOBALS['current_testcase']);
         }
     });
     $shutDownCallback = array('Menta_Bootstrap', 'closeSeleniumSession');
     if (function_exists('pcntl_signal')) {
         declare (ticks=1);
         pcntl_signal(SIGTERM, $shutDownCallback);
         pcntl_signal(SIGINT, $shutDownCallback);
     }
     register_shutdown_function($shutDownCallback);
     // will also be called on "PHP Fatal Error"
 }
Ejemplo n.º 2
0
    }
    // window size
    try {
        if ($configuration->issetKey('testing.selenium.windowSize')) {
            list($width, $height) = explode('x', $configuration->getValue('testing.selenium.windowSize'));
            $width = intval(trim($width));
            $height = intval(trim($height));
            if (empty($height) || empty($width)) {
                throw new Exception('Invalid window size');
            }
            $session->window('main')->size(array('width' => $width, 'height' => $height));
        }
    } catch (Exception $e) {
        // nevermind
    }
    // implicit wait
    try {
        if ($configuration->issetKey('testing.selenium.timeoutImplicitWait')) {
            $time = $configuration->getValue('testing.selenium.timeoutImplicitWait');
            $time = intval($time);
            $session->timeouts()->implicit_wait(array('ms' => $time));
        }
    } catch (Exception $e) {
        // nevermind
    }
});
// Provide configuration object to all components
Menta_Events::addObserver('after_component_create', function (Menta_Component_Abstract $component) {
    $component->setConfiguration(Menta_ConfigurationPhpUnitVars::getInstance());
});
// WebDriver_Base::$debugFile = 'debug.txt';
Ejemplo n.º 3
0
Menta_Events::addObserver('after_session_create', function (\WebDriver\Session $session, $forceNew) {
    $configuration = Menta_ConfigurationPhpUnitVars::getInstance();
    // window focus
    try {
        if ($configuration->issetKey('testing.selenium.windowFocus') && $configuration->getValue('testing.selenium.windowFocus')) {
            $session->window('main');
            // focus
        }
    } catch (Exception $e) {
        // nevermind
    }
    // window position
    try {
        if ($configuration->issetKey('testing.selenium.windowPosition')) {
            list($x, $y) = explode(',', $configuration->getValue('testing.selenium.windowPosition'));
            $x = intval(trim($x));
            $y = intval(trim($y));
            $session->window('main')->postPosition(array('x' => $x, 'y' => $y));
        }
    } catch (Exception $e) {
        // nevermind
    }
    // window size
    try {
        if ($configuration->issetKey('testing.selenium.windowSize')) {
            list($width, $height) = explode('x', $configuration->getValue('testing.selenium.windowSize'));
            $width = intval(trim($width));
            $height = intval(trim($height));
            if (empty($height) || empty($width)) {
                throw new Exception('Invalid window size');
            }
            $session->window('main')->postSize(array('width' => $width, 'height' => $height));
        }
    } catch (Exception $e) {
        // nevermind
    }
    // implicit wait
    try {
        if ($configuration->issetKey('testing.selenium.timeoutImplicitWait')) {
            $time = $configuration->getValue('testing.selenium.timeoutImplicitWait');
            $time = intval($time);
            $session->timeouts()->implicit_wait(array('ms' => $time));
        }
    } catch (Exception $e) {
        // nevermind
    }
});