Passionate
Passionate

Reputation: 139

How can I automate Silverlight application with selenium webdriver?

I'm new with Silverlight and Selenium. I searched to automate my Silverlight application with Selenium webdriver but I didn't find any useful source. Can someone guide me?

Cheers,

Upvotes: 2

Views: 6702

Answers (1)

marcelo.farias
marcelo.farias

Reputation: 91

It's possible to declare methods and attributes as [Scriptable] or a whole class as [ScriptableType]. This way you can invoke/access them via JavaScript, which can be done via WebDriver's executeScript and executeAsyncScript methods. In the class constructor, you can make the instance visible in the DOM by calling: HtmlPage.RegisterScriptableObject("AnyNameYouWant", this);

Note that no default WebDriver interaction (click, typeKeys) will work within your Silverlight object, so a click on a button, for instance, will have to be done programmatically like:

var peer = new ButtonAutomationPeer(button);
var ip = (IInvokeProvider)peer;
ip.Invoke();

The silverlight-selenium project (https://code.google.com/p/silverlight-selenium/) provides some fixtures for common UI components, relying solely on this JavaScript to Silverlight bridge. Unfortunately, this project is not currently active, but the examples should give you some insights.

Upvotes: 3

Related Questions