Skip to content
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

screen shot - extent report issues #44

Open
p00rni opened this issue Sep 17, 2021 · 5 comments
Open

screen shot - extent report issues #44

p00rni opened this issue Sep 17, 2021 · 5 comments

Comments

@p00rni
Copy link

p00rni commented Sep 17, 2021

HI

I hope it is ok to ask for help here regarding screenshots attachment to extent reports.
I have the following screen shot code in my framework to attach screenshots :

this method in a base page or a geneneric methods class 👍
public static byte[] getByteScreenShot() throws IOException {

	File src = ((TakesScreenshot) driver).getScreenshotAs(OutputType.FILE);
	byte[] fileContent = FileUtils.readFileToByteArray(src);
	return fileContent;

}

and i call this method in every cucumber steps class with below code to screenshot and attach for failed tests
@after
public void addScreenshot(Scenario scenario) throws IOException {
if (scenario.isFailed())
{
scenario.attach(BasePage.getByteScreenShot() , "image/png", ".png");}

this is taking screenshots fine but i notice that it is taking screenshot for every step instead of failed ones and are stored in screenshots folder as directed from extent.properties file.

but while attaching screenshots it is attaching irrelevant or wrong screenshots to the report.

is there a way to just take screenshot of only when test fails and not everystep ?

thanks

Poornima

@grasshopper7
Copy link
Owner

you can try with calling the method in afterstep hook with the if condition of scenario failure.

@p00rni
Copy link
Author

p00rni commented Sep 19, 2021

Its the same with afterStep and after .. after it is screenshot after the scenario and afterstep aftwr every step but still soing the same attaching irrelavent screenshots

@grasshopper7
Copy link
Owner

Need to see the relevant code before commenting. Create a shared repository with the minimum code which produces the issue.

@p00rni
Copy link
Author

p00rni commented Sep 20, 2021

hi

sure will share it shortly, meanwhile the automated scrips are executed in browserstack , the cloud device platform - could that a reason at all?

thanks

@p00rni
Copy link
Author

p00rni commented Oct 4, 2021

hi @grasshopper7 , apologies i am unable to share the code, but was wondering if i am having issues as i am running 4 tests in parallel , abd is there a different way to create extent report with screenshots , while tests are run in parallel, instead of the way i have followed ?
thanks

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants