How can I automate Silverlight application with selenium webdriver? How can I automate Silverlight application with selenium webdriver? selenium selenium

How can I automate Silverlight application with selenium webdriver?


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.