TestStack / TestStack.Seleno

Seleno helps you write automated UI tests in the right way by implementing Page Objects and Page Components and by reading from and writing to web pages using strongly typed view models.
http://teststack.github.com/TestStack.Seleno/
MIT License
180 stars 60 forks source link

Context file camera #185

Closed dennisroche closed 4 years ago

dennisroche commented 9 years ago

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 commented 9 years ago

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:

https://github.com/TestStack/TestStack.Seleno/pull/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 commented 9 years ago

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 commented 9 years ago

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 commented 9 years ago

This looks really useful.

dennisroche commented 9 years ago

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

mwhelan commented 9 years ago

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 commented 9 years ago

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 commented 9 years ago

@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 commented 9 years ago

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 commented 9 years ago

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 commented 9 years ago

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

robdmoore commented 9 years ago

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

dennisroche commented 6 years ago

Closing this PR as it over 3 years old.

robdmoore commented 6 years ago

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.

dennisroche commented 6 years ago

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

mwhelan commented 6 years ago

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 commented 6 years ago

@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