Skip to content

Instantly share code, notes, and snippets.

@mrunkel
Created December 10, 2018 12:33
Show Gist options
  • Save mrunkel/6ab93be3e4115267b9a74e910ecc7a52 to your computer and use it in GitHub Desktop.
Save mrunkel/6ab93be3e4115267b9a74e910ecc7a52 to your computer and use it in GitHub Desktop.
PHP method to take full screenshots in codeception
<?php
/**
* Inherited Methods
* @method void wantToTest($text)
* @method void wantTo($text)
* @method void execute($callable)
* @method void expectTo($prediction)
* @method void expect($prediction)
* @method void amGoingTo($argumentation)
* @method void am($role)
* @method void lookForwardTo($achieveValue)
* @method void comment($description)
* @method \Codeception\Lib\Friend haveFriend($name, $actorClass = NULL)
*
* @SuppressWarnings(PHPMD)
*/
class AcceptanceTester extends \Codeception\Actor
{
use _generated\AcceptanceTesterActions;
/**
* Define custom actions here
*/
public function makeFullScreenshot($name = null)
{
// set the width appropriately (to calc the height)
$this->resizeWindow(1920, 2000);
$docHeight = $this->executeJS('return document.body.scrollHeight');
// now reset the height to what's needed.
$this->resizeWindow(1920, $docHeight);
$this->makeScreenshot($name);
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment