Skip to content

MQE 1692: Improve makeScreenshot Action to Add Screenshot to Allure Report #443

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 4 commits into from
Sep 9, 2019
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
33 changes: 33 additions & 0 deletions src/Magento/FunctionalTestingFramework/Module/MagentoWebDriver.php
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@
use Magento\FunctionalTestingFramework\Util\Protocol\CurlTransport;
use Magento\FunctionalTestingFramework\Util\Protocol\CurlInterface;
use Magento\FunctionalTestingFramework\Util\ConfigSanitizerUtil;
use Yandex\Allure\Adapter\AllureException;
use Yandex\Allure\Adapter\Support\AttachmentSupport;
use Magento\FunctionalTestingFramework\Exceptions\TestFrameworkException;

Expand Down Expand Up @@ -196,6 +197,7 @@ public function _getCurrentUri()
*
* @param string $url
* @return void
* @throws AllureException
*/
public function dontSeeCurrentUrlEquals($url)
{
Expand All @@ -210,6 +212,7 @@ public function dontSeeCurrentUrlEquals($url)
*
* @param string $regex
* @return void
* @throws AllureException
*/
public function dontSeeCurrentUrlMatches($regex)
{
Expand All @@ -224,6 +227,7 @@ public function dontSeeCurrentUrlMatches($regex)
*
* @param string $needle
* @return void
* @throws AllureException
*/
public function dontSeeInCurrentUrl($needle)
{
Expand Down Expand Up @@ -261,6 +265,7 @@ public function grabFromCurrentUrl($regex = null)
*
* @param string $url
* @return void
* @throws AllureException
*/
public function seeCurrentUrlEquals($url)
{
Expand All @@ -275,6 +280,7 @@ public function seeCurrentUrlEquals($url)
*
* @param string $regex
* @return void
* @throws AllureException
*/
public function seeCurrentUrlMatches($regex)
{
Expand All @@ -289,6 +295,7 @@ public function seeCurrentUrlMatches($regex)
*
* @param string $needle
* @return void
* @throws AllureException
*/
public function seeInCurrentUrl($needle)
{
Expand Down Expand Up @@ -645,6 +652,7 @@ public function dragAndDrop($source, $target, $xOffset = null, $yOffset = null)
* @param string $field
* @param string $value
* @return void
* @throws TestFrameworkException
*/
public function fillSecretField($field, $value)
{
Expand Down Expand Up @@ -791,4 +799,29 @@ public function dontSeeJsError()
{
$this->assertEmpty($this->jsErrors, $this->getJsErrors());
}

/**
* Takes a screenshot of the current window and saves it to `tests/_output/debug`.
*
* This function is copied over from the original Codeception WebDriver so that we still have visibility of
* the screenshot filename to be passed to the AllureHelper.
*
* @param string $name
* @return void
* @throws AllureException
*/
public function makeScreenshot($name = null)
{
if (empty($name)) {
$name = uniqid(date("Y-m-d_H-i-s_"));
}
$debugDir = codecept_log_dir() . 'debug';
if (!is_dir($debugDir)) {
mkdir($debugDir, 0777);
}
$screenName = $debugDir . DIRECTORY_SEPARATOR . $name . '.png';
$this->_saveScreenshot($screenName);
$this->debug("Screenshot saved to $screenName");
AllureHelper::addAttachmentToCurrentStep($screenName, 'Screenshot');
}
}