Timon Timon - 4 years ago 124
C# Question

Can't use Telerik Testing Framework from web application

I recently starting fiddling around with the Telerik Test Framework ( http://www.telerik.com/teststudio/testing-framework ).

I used this to set up automated browser tests.
At first i used them in classical test project in Visual Studio and everything worked fine.

Next i wanted to be able to use the automated browser outside of Visual Studio. So i create a console application where i used the framework for my automated browser, and everything worked fine.

Next i wanted to create a MVC project where i used the framework for the automated browser, and everything stopped working.

It seems like that for some reason when the automated browser is called from a web application that the selected browser won't start up.

The actual code were the automated browser is started is the same for the web app and the console app. Just different starting points.

I also don't get any errors about the browser not starting up, i simply end up with a time out exception from the framework after i want to launch the browser.

Console code:

namespace AutomatedTests
{
class Program
{
static void Main(string[] args)
{
var telerik = new TelerikTests();
telerik.TestLanguageCoockie();
}
}
}


Web application code:

namespace AutomatedTests.Controllers
{
public class BrowserTestController : Controller
{
public ActionResult Index()
{
var telerikTests = new TelerikTests();
telerikTests.TestLanguageCoockie();
}
}
}


TelerikTests code:

namespace AutomatedTests.Tests
{
[TestClass]
public class TelerikTests : BaseTest
{
private static Settings settings;

public TelerikTests()
{
Init();
}

private Manager createMyManager
{
get
{
return new Manager(settings); // = ArtOfTest.WebAii.Core.Manager
}
}

public void Init()
{
// Get basic settings.
settings = GetSettings(); // = BaseTest.GetSettings();

// Custumize away!
settings.Web.DefaultBrowser = BrowserType.Chrome;
settings.Web.KillBrowserProcessOnClose = true;
}

[TestMethod]
public void TestLanguageCoockie()
{
var myManager = createMyManager;
myManager.Start();

myManager.LaunchNewBrowser();

// More code to perform the actual test, but with the web app approach we never get past this. The browser doesn't start and a time out exception is thrown.

}
}
}


EDIT: It turns out that i have this issue for every browser, except IE. But i do need it working for the other browsers as well.

Answer Source

I ended up setting up a console project + a web application. The web application contacts the console application so that it can perform all the automated browser tasks. Later it send the information back to the web app so that it can send it back to the client.

Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download