Skip to content

Context file camera #185

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

Closed
wants to merge 9 commits into from
Closed

Context file camera #185

wants to merge 9 commits into from

Conversation

dennisroche
Copy link

A new file camera that bakes additional/contextual information into the image. I found this additional information useful when debugging why a test failed and where in the callstack the image was generated.

To make this information even more useful, I added Exception param to the ICamera.TakeScreenshot interface. It defaults to null.

Example

elementfinder_2014-11-03_15-00-59 png_130595004593300652

Usage

_host = new SelenoHost();
_host.Run(x => x
    .UsingCamera(new ContextFileCamera(CameraFolderPath, typeof(TestAttribute)))
    .WithWebServer(new InternetWebServer("http://www.google.com/"))
    .WithMinimumWaitTimeoutOf(TimeSpan.FromMilliseconds(100))
);

I'm not too happy with the having to pass down the attribute type that decorate the test, i.e. typeof(TestAttribute) for NUnit. However I couldn't think of a generic way to handle this.

@robdmoore
Copy link
Member

This looks great.

I vote we remove the test attribute and bake in support for select test frameworks (mstest, nunit, xunit, fixie, mbunit to start). If there are any others people want we can respond to them raising an issue. You can just have a list of strings of their assembly and type name for comparison.

I wonder if we can create an approval test that compares the image to an expected one?

wrote:

A new file camera that bakes additional/contextual information into the image. I found this additional information useful when debugging why a test failed and where in the callstack the image was generated.

To make this information even more useful, I added Exception param to the ICamera.TakeScreenshot interface. It defaults to null.

Example

Usage

_host = new SelenoHost();
_host.Run(x => x
.UsingCamera(new ContextFileCamera(CameraFolderPath, typeof(TestAttribute)))
.WithWebServer(new InternetWebServer("http://www.google.com/"))
.WithMinimumWaitTimeoutOf(TimeSpan.FromMilliseconds(100))
);
I'm not too happy with the having to pass down the attribute type that decorate the test, i.e. typeof(TestAttribute) for NUnit. However I couldn't think of a generic way to handle this.

You can merge this Pull Request by running

git pull https://github.com/dennisroche/TestStack.Seleno ContextFileCamera
Or view, comment on, or merge it at:

#185

Commit Summary

Added FileContextCamera. Renders a screenshot with additional information baked into the image, e.g. PageTitle, Url, Current Callstack.
TakeScreenshot now accepts optional Exception argument. Useful information that could be recorded in the screenshot.
Made impl same as ICamera interface
File Changes

M src/TestStack.Seleno/Configuration/Contracts/ICamera.cs (6)
M src/TestStack.Seleno/Configuration/Interceptors/CameraProxyInterceptor.cs (2)
A src/TestStack.Seleno/Configuration/Screenshots/ContextFileCamera.cs (134)
M src/TestStack.Seleno/Configuration/Screenshots/FileCamera.cs (2)
M src/TestStack.Seleno/Configuration/Screenshots/NullCamera.cs (3)
M src/TestStack.Seleno/TestStack.Seleno.csproj (1)
Patch Links:

https://github.com/TestStack/TestStack.Seleno/pull/185.patch
https://github.com/TestStack/TestStack.Seleno/pull/185.diff

Reply to this email directly or view it on GitHub.

@dennisroche
Copy link
Author

I agree with you re: baking in support for other test frameworks. I'll look into the cleanest way to implement it.

I like the idea of an approval test that compares images. Would need to create a test page and set SystemTime to keep it stable, otherwise it would break when Google updates their homepage.

@robdmoore
Copy link
Member

Don't use google. Use a page on the acceptance tests web project so it's stable.

On 4 Nov 2014, at 6:52 am, Dennis Roche notifications@github.com wrote:

I agree with you re: baking in support for other test frameworks. I'll look into the cleanest way to implement it.

I like the idea of an approval test that compares images. Would need to create a test page and set SystemTime to keep it stable, otherwise it would break when Google updates their homepage.


Reply to this email directly or view it on GitHub.

@mwhelan
Copy link
Member

mwhelan commented Nov 4, 2014

This looks really useful.

@dennisroche
Copy link
Author

Thanks @mwhelan. I showed it to @robdmoore and has encouraged me to contribute it back to the project.

@mwhelan
Copy link
Member

mwhelan commented Nov 4, 2014

Yeah, things like this really add a lot of value for developers/testers and take a little bit more pain away from testing. It's always great to get more of those sorts of features.

@robdmoore
Copy link
Member

Hey @dennisroche what's the status on changing that test attribute? Do you think we should merge in the meantime regardless and do that in a separate PR? I also wonder if we can do an acceptance test of this with an image comparison - main tricky thing would be the date (maybe we can figure a way to fix it for the test?).

@dennisroche
Copy link
Author

@robdmoore I haven't made any progress on it. I did spike an idea, however it got left on the wayside months ago. I will have make time on Thursday night to revisit this and get it to merge ready state with test attribute removed and an acceptance test.

For the acceptance test, I was going to use/create a page in the current test project and then fix the time using the SystemTime package that @mwhelan recently introduced to the solution.

@dennisroche
Copy link
Author

Rebased with master. I've made the suggested changes to detecting the testing framework and added an acceptance test for the ContextFileCamera that compares the image.

@robdmoore
Copy link
Member

You are going to need to set the browser window size to a certain size otherwise it will vary based on the computer it's running on. For instance, that test failed on the build server.

Don't make it more than 800x600 as a lowest common denominator.

On 19 Feb 2015, at 9:41 pm, Dennis Roche notifications@github.com wrote:

Rebased with master. I've made the suggested changes to detecting the testing framework and added an acceptance test for the ContextFileCamera that compares the image.


Reply to this email directly or view it on GitHub.

@dennisroche
Copy link
Author

Thanks @robdmoore. I thought that would happen as I had the test fail locally once with a image of different dimensions.

@robdmoore
Copy link
Member

FYI There are a bunch of broken acceptance tests on your latest commit in the build server.

@dennisroche
Copy link
Author

Closing this PR as it over 3 years old.

@robdmoore
Copy link
Member

This is still incredibly useful. The main issue is that Seleno hasn't received any love for a long time. I'd prefer this is left open to it's clear if Seleno is ressurected at any point.

@robdmoore robdmoore reopened this Feb 19, 2018
@dennisroche
Copy link
Author

Fair enough; it would be good to see Seleno live again.

@mwhelan
Copy link
Member

mwhelan commented Feb 21, 2018

Hey Dennis

I'm the original creator of Seleno and I would love to see it live again too. When I made it I was doing a lot of Selenium WebDriver work but it's been quite awhile since I've used Selenium and it's been hard to keep up with the project. It would be good to start off with supporting the latest version of WebDriver and investigate what might be involved with porting it to .Net Core. I think that would be possible with .Net Core 2.0.

Thanks

@dennisroche
Copy link
Author

@mwhelan perhaps that is why it has dropped to the side as not many people are using Selenium UI testing, especially on ASP.NET MVC apps (it has been years since I last created one).

It would be good to start off with supporting the latest version of WebDriver and investigate what might be involved with porting it to .Net Core. I think that would be possible with .Net Core 2.0.

Porting to .NET Core 2 looks possible (see attached report). Probably would have some serious breaking changes for existing users because of ASPNET.Core

Seleno - I Can Has .NET Core.pdf

@dennisroche dennisroche closed this Aug 6, 2020
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

Successfully merging this pull request may close these issues.

3 participants