-
-
Save anonymous/85a800635ae0201f9f7e to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
package Autotest.common.listeners; | |
import Autotest.common.utils.Attacher; | |
import Autotest.common.utils.TimeHelper; | |
import ru.yandex.qatools.allure.events.StepFinishedEvent; | |
import ru.yandex.qatools.allure.events.StepStartedEvent; | |
import ru.yandex.qatools.allure.experimental.LifecycleListener; | |
/** | |
* | |
* @author Fiat | |
*/ | |
public class LifecycleListenerBell extends LifecycleListener{ | |
private static final boolean SCREENSHOT_AFTER_STEP = Boolean.parseBoolean(System.getProperty("allure.screenshot.afterStep", "true")); | |
private static final boolean SCREENSHOT_BEFORE_STEP = Boolean.parseBoolean(System.getProperty("allure.screenshot.beforeStep", "false")); | |
@Override | |
public void fire(StepStartedEvent event) { | |
String title = event.getTitle(); | |
if(title != null && !title.isEmpty()) | |
{ | |
title = title.replace("\n", "</br>"); | |
event.setTitle(title); | |
title = event.getTitle(); | |
if(!(title.contains("ОЖИДАЕТСЯ:</span>"))) | |
{ | |
event.withTitle(title.replace("ОЖИДАЕТСЯ:", "<span style=\"color:#0000CC\">ОЖИДАЕТСЯ:</span>")); | |
} | |
} | |
if(event.getName() != null) { | |
System.out.println("STEP ["+TimeHelper.getDateAndTime("H:mm:ss")+"]: " + event.getName()); | |
} else | |
{ | |
System.out.println("STEP ["+TimeHelper.getDateAndTime("H:mm:ss")+"]: without name"); | |
} | |
if(SCREENSHOT_BEFORE_STEP) { | |
Attacher.attachScreenshotByDriver(); | |
} | |
} | |
@Override | |
public void fire(StepFinishedEvent event) { | |
System.out.println("STEP ["+TimeHelper.getDateAndTime("H:mm:ss")+ "] --------------------------- end"); | |
if(SCREENSHOT_AFTER_STEP) { | |
Attacher.attachScreenshotByDriver(); | |
} | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment