Take the 2-minute tour ×
Stack Overflow is a question and answer site for professional and enthusiast programmers. It's 100% free, no registration required.

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.

share|improve this question
    
    
@AlexandruG. This is not what I'm looking for... The browser stays open and I want to close it. –  Kuvi Oct 9 '14 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(). –  Alexandru Guzinschi Oct 9 '14 at 12:37
    
@AlexandruG. Already tried it. It does nothing because the code crashes before. –  Kuvi Oct 9 '14 at 13:12
    
Try adding $this->shareSession(false); before $this->open('http://www.google.com/'); –  Alexandru Guzinschi Oct 9 '14 at 13:25

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Browse other questions tagged or ask your own question.