CefGlue and Visual Studio unit tests

Having problems with building or using the CefGlue .NET/Mono binding? Ask your questions here.

Moderator: fddima

CefGlue and Visual Studio unit tests

Postby Pavel » Mon Aug 06, 2012 5:19 am

With CefGlue and Visual Studio unit testing framework I want to accomplish the following scenario:
1. load some html into browser (or alternatively some url)
2. test some assertions about DOM model in javascript

No windows should be displayed, everything should run in background threads. Can I achieve this with CefGlue? If so, could you please provide some example code?
Pavel
Newbie
 
Posts: 1
Joined: Mon Aug 06, 2012 5:11 am

Re: CefGlue and Visual Studio unit tests

Postby fddima » Mon Aug 06, 2012 12:26 pm

I think that it is possible. Some peoples exactly using CEF for this, as i know.
But i' doesn't hear about ready to use solution. May be Selenium it is exactly what you want?

Pavel wrote:1. load some html into browser (or alternatively some url)

It can be done with CEF easily. Check documentation, and methods like LoadUrl / LoadString. As for me is better write own scheme handler and load anything via urls.

Pavel wrote:2. test some assertions about DOM model in javascript

You can visit DOM with CEF (only from renderer process (of course it will available from browser process in single process mode)).
But as for me - more easily inject you minimal testing JS framework in testing page and call it from you tests. It must be not so hard, and much easier than using CEF DOM API.

Pavel wrote:No windows should be displayed, everything should run in background threads. Can I achieve this with CefGlue? If so, could you please provide some example code?

1. Using off-screen rendering (currently available only with CEF 1)...
2. Just hiding windows (may affect on layouting, but in general it must work)... JS alerts/dialogs can be handled on to auto answering via CEF.

You need find way to initalize cef runtime and then just create / drop browsers when you need.
I suggest start from examine test application, and try to integrate with you testing framework.
Sorry, but we doesn't use mstest / xunit / nunit, so i can't say what concrete steps you need.
But mstest have AssemblyInitialize / AssemblyCleanup attributes, so it is looks as can be used, but i'm never try it.
Also i do something like before with nunit and cefsharp, so it will possible and not so hard.
May be have sense check CefSharp.Test as starting point.
fddima
Master
 
Posts: 788
Joined: Tue Dec 07, 2010 6:10 am


Return to CefGlue Forum

Who is online

Users browsing this forum: No registered users and 20 guests