phpunit-selenium icon indicating copy to clipboard operation
phpunit-selenium copied to clipboard

Shared session not stopped after last test for browser - using multible browsers

Open PatricB opened this issue 10 years ago • 1 comments

When I run my test with multible browsers ($browsers array) and session strategy shared, the session of the first browser don't stop after the last test. Until timeout the next session for the next browsers starts.

It would be nice, if until the last test for one browser session, the session would be stopped.

PatricB avatar Oct 01 '15 15:10 PatricB

change suggestion for Selenium2TestCase.php:

   public function tearDown()
    {
        parent::tearDown();
        if ($this->getName() === $this->getLastTest()) {
            $this->stop();
        }
    }

    function getLastTest()
    {
        $tests = array_filter(get_class_methods($this), function($method){
            $reClassName = "/test[A-Z][a-zA-Z]+/";
            preg_match($reClassName, $method, $matchClassName);

            $reAnnotation = "/@test/";
            $rm = new \ReflectionMethod($this, $method);
            $docComment = $rm->getDocComment();
            preg_match($reAnnotation, $docComment, $matchAnnotation);

            return(!empty($matchClassName) || !empty($matchAnnotation));
        });
        return end($tests);
    }

When I have time , I'm going to create a pull request for this. :)

PatricB avatar Oct 02 '15 13:10 PatricB