dougnoel / sentinel

A Selenium/Appium framework that enables users to focus on automating web and windows tests, so that automated tests can be written in a non-technical way in the same amount of time as manual tests can be executed.
Apache License 2.0
11 stars 13 forks source link

Refactoring Windows Screenshots #361

Open pturchinetz opened 2 years ago

pturchinetz commented 2 years ago

All windows switching code should be outside of cucumber steps

pturchinetz commented 2 years ago

src/main/java/com/dougnoel/sentinel/system/FileManager.java: line 137 1.) If you throw an exception it must be listed in the Javadocs or you'll get an error when compiling them. 2.) All exceptions that would interrupt a thread should be wrapped in a runtime exception. That is the point of the com.sentinel.dougnoel.exceptions.IOException In this way the test fails, but the entire test run does not.

dougnoel commented 2 years ago

Additional thoughts:

The overall architecture should be a ScreenShot object can be called. Underneath it determines what needs to be done to take the screenshot and makes sure they are stored in a way that makes them all return as the same format. It also would allow comparison. Then you would be able to compare between different types. This would also allow the seamless implementation of Applitools.

Methods: ScreenShot() //creates a blank screenshot ready to be captured.

ScreenShot(File filename) //loads a screenshot from disk

ScreenShot(BufferedImage image) //creates a screenshot from a buffered image for use in comparison)

ScreenShot.desktop() //Grabs the active or first desktop. Later implementation could include an override passing in which desktop to screenshot.

ScreenShot.window() //Grab current active window.

ScreenShot.element(String elementName) //grabs the active element

ScreenShot.getBackgroundColor() //samples the screenshot and gets the most prevalent color as the background color https://gist.github.com/jittagornp/6c7fcdab388fe4863c34

ScreenShot.equals(ScreenShot screenshot) //Does this image equal the image being passed?

ScreenShot.contains(ScreenShot screenshot) //Does this image contain the image being passed?

Implementation: