If you need to view the contents of a page when running a \Drupal\Tests\BrowserTestBase test then you can use the following technique.
/**
* Test that a user can access their own referral tab.
*/
public function testUserCanAccessTheirOwnReferralTab() {
$user = $this->drupalCreateUser();
$this->drupalLogin($user);
$this->drupalGet('user/' . $user->id());
fwrite(STDERR, var_export($this->getSession()->getPage()->getContent(), TRUE));
// Continue testing here.
}
This will render the current session page content to the command line, which is useful if you are unable to view the output of the test run. This might be the case when running tests in a continuous integration environment.
Add new comment