Open anqon opened 1 year ago
@anqon I don't think your issue is the screenshot format itself - it's the fact nothing calls the CucumberJSONFormatter.embedding()
. To make things a little bit more "interesting", if I recall well, after_step()
will get executed before the formatter formats the output. One way of working around this would be in after_step()
capture the screenshot location and override https://github.com/BluThaitanium/Cucumber-Behave-Package/blob/main/behave_cucumber_formatter/__init__.py#L135 such that it attaches your captured screenshot.
Hi @anqon, Were you able to embed the screenshots? Would you please share how you did it? Thank you,
@kconkas Hi mate, it looks like you have some idea on the matter. Can you advice on :
def after_step(context, step):
if step.status == 'failed':
try:
if hasattr(context, 'driver'):
screenshot_path = f"{CONSTANT.CUCUMBER_REPORTS_LOCATION}/{step.name}.png"
context.driver.save_screenshot(screenshot_path)
attach_screenshot(context, screenshot_path)
else:
print("No driver found in context. Unable to capture screenshot.")
except Exception as e:
print(f"Failed to capture and embed screenshot: {e}")
def attach_screenshot(context, screenshot_data):
try:
if hasattr(context, 'attach'):
context.attach(screenshot_data, 'image/png')
else:
print("No attachment method ('attach') available in context.")
except Exception as e:
print(f"Failed to attach screenshot: {e}")
With the same error as above ?
Failed to attach screenshot: 'embeddings'
What is causing it and how it can be resolve ? Sorry to bother you, but tbh I tried everything :D
Versions:
behave @ git+http://github.com/behave/behave.git@9520119376046aeff73804b5f1ea05d87a63f370
behave-cucumber-formatter==1.0.1
Hi after time i don't remember what was the main problem in my code. But now everything working I remember that I needed to: -use behave newest than 1.2.6 version -> 1.2.7dev
I use PrettyCucumberJSONFormatter with that code and everything is correct attached to the report file
@anqon thanks mate! Worked as charm on 1.2.7dev4.
Hi @BluThaitanium , Could you help me how should be looks like correct after step imprepentation to attach ebmedings? I tried that ` def after_step(context, step):
tried also screenshot = context.driver.save_screenshot("screenshot.png") and screenshot =context.driver.get_screenshot_as_png() and screenshot =context.driver.get_full_page_screenshot_as_png() - that's not supported by appium webdriver
but I I have: HOOK-ERROR in after_step: KeyError: 'embeddings' I don't know wchich form of make screenshot is good for this format...
(python3.11 +appium + behave 1.2.7.dev2)