keeping selenium browser open with phpunit/selenium

后端 未结 6 2017
我在风中等你
我在风中等你 2020-12-30 13:33

when the tests fail, the browser that the selenium tests were running on closes. this is unhelpful when trying to debug. i know i have the option of a screen shot upon failu

6条回答
  •  半阙折子戏
    2020-12-30 13:57

    A simple solution is to set the session $stopped property to true, in the test setUp() method. As the property is private, we need to use the Reflection api.

        function setUp() {
    
            ....
    
            // Set the private property $stopped of session to true, so the window is not closed on error or at the end of tests
            $myClassReflection = new \ReflectionClass( get_class( $this->prepareSession() ) );
            $secret            = $myClassReflection->getProperty( 'stopped' );
            $secret->setAccessible( true );
            $secret->setValue( $this->prepareSession(), true );
    
            ...
    }
    

提交回复
热议问题