How to use getScreenshotPreferences method of net.serenitybdd.cucumber.util.StepDefinitionAnnotationReader class

Best Serenity Cucumber code snippet using net.serenitybdd.cucumber.util.StepDefinitionAnnotationReader.getScreenshotPreferences

Source:SerenityReporter.java Github

copy

Full Screen

...236 StepDefinitionAnnotationReader237 .withScreenshotLevel((TakeScreenshots) systemConfiguration.getScreenshotLevel()238 .orElse(TakeScreenshots.UNDEFINED))239 .forStepDefinition(event.getTestStep().getCodeLocation())240 .getScreenshotPreferences());241 if (!(event.getTestStep() instanceof HookTestStep)) {242 if (event.getTestStep() instanceof PickleStepTestStep) {243 PickleStepTestStep pickleTestStep = (PickleStepTestStep) event.getTestStep();244 TestSourcesModel.AstNode astNode = featureLoader.getAstNode(getContext().currentFeaturePath(), pickleTestStep.getStepLine());245 if (astNode != null) {246 io.cucumber.core.internal.gherkin.ast.Step step = (io.cucumber.core.internal.gherkin.ast.Step) astNode.node;247 if (!getContext().isAddingScenarioOutlineSteps()) {248 getContext().queueStep(step);249 getContext().queueTestStep(event.getTestStep());250 }251 if (getContext().isAScenarioOutline()) {252 int lineNumber = event.getTestCase().getLine();253 getContext().stepEventBus().updateExampleLineNumber(lineNumber);254 }...

Full Screen

Full Screen

Source:StepDefinitionAnnotationReader.java Github

copy

Full Screen

...28 }29 public static Builder withScreenshotLevel(TakeScreenshots screenshotLevel) {30 return new Builder(screenshotLevel);31 }32 public TakeScreenshots getScreenshotPreferences() {33 if (stepDefinitionPath == null) {34 return TakeScreenshots.UNDEFINED;35 }36 List<Annotation> stepDefinitionAnnotations = annotationsIn(className(), methodName());37 return stepDefinitionAnnotations.stream()38 .filter(annotation -> annotation instanceof Screenshots)39 .map(annotation -> asEnum((Screenshots) annotation))40 .findFirst()41 .orElse(screenshotDefaultLevel);42 }43 private TakeScreenshots asEnum(Screenshots screenshotAnnotation) {44 if (screenshotAnnotation.disabled()) {45 return TakeScreenshots.DISABLED;46 } else if (screenshotAnnotation.afterEachStep()) {...

Full Screen

Full Screen

Source:StepDefinitionAnnotationReaderTest.java Github

copy

Full Screen

...7 public void should_read_annotations_from_a_step_definition_method_name() {8 assertThat(9 StepDefinitionAnnotationReader10 .forStepDefinition("net.serenitybdd.cucumber.util.SampleStepDefinitions.aStepDefinitionWithAScreenshotAnnotation()")11 .getScreenshotPreferences()12 ).isEqualTo(TakeScreenshots.DISABLED);13 }14 @Test15 public void should_read_annotations_from_a_parameterised_step_definition_method_name() {16 assertThat(17 StepDefinitionAnnotationReader18 .forStepDefinition("net.serenitybdd.cucumber.util.SampleStepDefinitions.aStepDefinitionWithAParameter(java.lang.String)")19 .getScreenshotPreferences()20 ).isEqualTo(TakeScreenshots.DISABLED);21 }22 @Test23 public void screenshot_preference_is_undefined_if_no_annotation_is_present() {24 assertThat(25 StepDefinitionAnnotationReader26 .forStepDefinition("net.serenitybdd.cucumber.util.SampleStepDefinitions.aStepDefinitionWithNoScreenshotAnnotation()")27 .getScreenshotPreferences()28 ).isEqualTo(TakeScreenshots.UNDEFINED);29 }30 @Test31 public void screenshot_preference_is_before_and_after_each_step_by_default_if_no_annotation_is_present() {32 assertThat(33 StepDefinitionAnnotationReader34 .forStepDefinition("net.serenitybdd.cucumber.util.SampleStepDefinitions.aStepDefinitionWithAScreenshotAnnotationWithNoAttribute()")35 .getScreenshotPreferences()36 ).isEqualTo(TakeScreenshots.BEFORE_AND_AFTER_EACH_STEP);37 }38}...

Full Screen

Full Screen

getScreenshotPreferences

Using AI Code Generation

copy

Full Screen

1 @Given("^I set the screenshot preferences to (.*)$")2 public void setScreenshotPreferences(String preferences) {3 StepDefinitionAnnotationReader reader = new StepDefinitionAnnotationReader();4 reader.getScreenshotPreferences(this.getClass().getDeclaredMethod("setScreenshotPreferences", String.class));5 System.out.println("Screenshot preferences are: " + screenshotPreferences);6 }7 @Given("^I set the screenshot preferences to (.*)$")8 public void setScreenshotPreferences(String preferences) {9 StepDefinitionAnnotationReader reader = new StepDefinitionAnnotationReader();10 reader.getScreenshotPreferences(this.getClass().getDeclaredMethod("setScreenshotPreferences", String.class));11 System.out.println("Screenshot preferences are: " + screenshotPreferences);12 }13 @Given("^I set the screenshot preferences to (.*)$")14 public void setScreenshotPreferences(String preferences) {15 StepDefinitionAnnotationReader reader = new StepDefinitionAnnotationReader();16 reader.getScreenshotPreferences(this.getClass().getDeclaredMethod("setScreenshotPreferences", String.class));17 System.out.println("Screenshot preferences are: " + screenshotPreferences);18 }19 @Given("^I set the screenshot preferences to (.*)$")20 public void setScreenshotPreferences(String preferences) {21 StepDefinitionAnnotationReader reader = new StepDefinitionAnnotationReader();22 reader.getScreenshotPreferences(this.getClass().getDeclaredMethod("setScreenshotPreferences", String.class));23 System.out.println("Screenshot preferences are: " + screenshotPreferences);24 }25 @Given("^I set the screenshot preferences to (.*)$")26 public void setScreenshotPreferences(String preferences) {27 StepDefinitionAnnotationReader reader = new StepDefinitionAnnotationReader();28 reader.getScreenshotPreferences(this.getClass().getDeclaredMethod("setScreenshotPreferences", String.class));29 System.out.println("Screenshot preferences are: " + screenshotPreferences);30 }

Full Screen

Full Screen

Automation Testing Tutorials

Learn to execute automation testing from scratch with LambdaTest Learning Hub. Right from setting up the prerequisites to run your first automation test, to following best practices and diving deeper into advanced test scenarios. LambdaTest Learning Hubs compile a list of step-by-step guides to help you be proficient with different test automation frameworks i.e. Selenium, Cypress, TestNG etc.

LambdaTest Learning Hubs:

YouTube

You could also refer to video tutorials over LambdaTest YouTube channel to get step by step demonstration from industry experts.

Run Serenity Cucumber automation tests on LambdaTest cloud grid

Perform automation testing on 3000+ real desktop and mobile devices online.

Most used method in StepDefinitionAnnotationReader

Try LambdaTest Now !!

Get 100 minutes of automation test minutes FREE!!

Next-Gen App & Browser Testing Cloud

Was this article helpful?

Helpful

NotHelpful