0

I'm doing testing in PHPUnit+Selenium (using PHPUnit_Extensions_SeleniumTestCase) and I need to do something to close browser even if the test result on error. Let's see, I've done this test:

<?php
require_once 'PHPUnit/Extensions/SeleniumTestCase.php';

class WebTest extends PHPUnit_Extensions_SeleniumTestCase
{
    protected $fail;
    protected function setUp()
    {
        $this->setBrowser('*chrome');
        $this->setBrowserUrl('http://www.google.com/');
    }

    public function testTitle()
    {
        $this->open('http://www.google.com/');
        $this->assertTitle($this->fail->value());
    }
}
?>

Which result on error caused by:

$this->assertTitle($this->fail->value());

Because there is not value in $fail and then the test finishes getting an error. The problem is that the browser remains open in Selenium. How can I force to close browser from Selenium?

Thx in advance.

6
  • See stackoverflow.com/questions/5940214/… Commented Oct 9, 2014 at 11:17
  • @AlexandruG. This is not what I'm looking for... The browser stays open and I want to close it. Commented Oct 9, 2014 at 12:27
  • The idea of my previous comment was to check if you enabled browserSessionReuse and forgot about it. You could also try with $this->stop(). Commented Oct 9, 2014 at 12:37
  • @AlexandruG. Already tried it. It does nothing because the code crashes before. Commented Oct 9, 2014 at 13:12
  • Try adding $this->shareSession(false); before $this->open('http://www.google.com/'); Commented Oct 9, 2014 at 13:25

0

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.