9

I am running codeception 2 with selenium. I can see selenium open the browser and run through the tests. Then I get an error from codeception that there is a failed assertion.

I know there is an HTML file that is saved, but there is a lot of JS, so I can't really analyze that. I need the firefox window to stay open so I can see the output and figure out what is wrong.

How can I do this? I am already running selenium with -browserSessionReuse

If it makes a difference, it's happening inside $I->haveFriend(); $friend->does() statement.

DAB
  • 1,303
  • 14
  • 23

2 Answers2

2

There no straight solution how to do this, but some tricks can be used:

  1. Use interactive console, follow same steps as in scenario, use assertions which fail - selenium stay open, so you can debug and evaluate what happens.
  2. Use trick with wait. In cest file add "__fail" method where place "wait(300)" (for 5 min). Than on test launch your browser will stay open for 5 min
1

If you are running Cest style tests, try

public function _failed(AcceptanceTester $I)
{
     $I->pauseExecution();
}

That will hold the browser window open until you hit enter in case of a failure.

Alternatively, you could take a screenshot upon test failure.

public function _failed(AcceptanceTester $I)
    {
        $I->makeScreenshot('test_failed_screenshot' . time());
    }

This will save a screenshot at the point of failure in tests > output > debug. My cests have several tests within them, so I use the time() to give variation to the failed screenshot names to ensure I have a screenshot for every failed tests.

CosetteN
  • 347
  • 1
  • 7
  • 18
  • I find that $I->pauseExection() doesn't work (it doesn't pause / wait for Enter ). from the docs http://codeception.com/docs/modules/WebDriver#pauseExecution it says it will pause if system is in debug mode - how to put it in debug mode ? – gvanto Sep 27 '17 at 08:27
  • 1
    have you tried running your test with the debug flag? codecept run --debug {testname} – CosetteN Sep 28 '17 at 19:58