Controlling SilverLight application using selenium does not work - silverlight

I am trying to automate an web application where in I am trying to control the silver light application.
I need to play pause and stop the player embedded in HTML.
There is an object tag which has an id for player.
I am trying to execute the JavaScript as follows
return document.getElementById('wptv_services_common_widgets_player_silverlight_PlayerObject_0').CurrentState
How ever I am not getting anything in return. What I get is just None as a result.
Similarly I also try to pause the player but I get different errors:
document.getElementById('wptv_services_common_widgets_player_silverlight_PlayerObject_0').Pause()
but i get
error: 'document.getElementById(...).Pause is not a function'
If I edit the code to use with ' () ' then there is no error but nothing happens on the video ie. it does not pause.
Note: I got the link How do I pause/play/seek a silverlight video using javascript and this is exactly what i want to achieve but the solution mentioned is not working for me.
I worked for youtube player and reference their API and similar functions were working just fine.
I am not familiar with silver-light application myself so a bit detailed information will be helpful.
Any help will be highly appreciated.

Silverlight doesn't expose a DOM that is accessible to Selenium. If you have the sourcecode to the Silverlight application, you can expose specific functions to javascript host.
If you don't have source, you can use TestStack.White with Silverlight. Although it may be a bit clunky (because it works with standard accessibility that's built into Silverlight), it works.
For more information see https://github.com/TestStack/White

Related

Windows UI Automation tools (Visual UIAVerify, Inspect.exe) recognizes the Buttons as Pane

I am using UI Automation library - TestStack.White to automate a Windows Application, where I utilize Inspect.exe to get the UI Elements from the WinForms. I have had no issues with the Inspect.exe so far except currently I am stuck with an issue in my development machine where the tool started recognizing the "Buttons" as "Pane" and the behavior is same across Visual UIA Verify, TestStack(White). Eventually all the tests are getting failed since it couldn't identify the Buttons (returns Null).
Here's what it looks like now,
[]
Here's what it used to look and it looks in a Fresh VM,
Expected,
[]
Can someone please through some light regarding this behavior or point out what would have gone wrong here ?
Thanks in Advance !
Hmm... It looks like a bug in UIAutomationCore.dll or a target application issue. I think you can't do something with that on client side. But some workarounds are possible. It's still recognized as a class name with BUTTON inside. So it's possible to do some part of your automation with a tool that can support both UI Automation (for complicated controls like WinForms list views etc) and Win32 API (like here, when it has NativeWindowHandle and adequate ClassName).
If you can consider changing the automation tool, one of the options is pywinauto. It can use Win32 API or UI Automation under the hood by your choice. The high level API is almost the same. So you can easily switch between 2 backends for different actions (having 2 different Application objects connected to one target app instance). Getting Started Guide will bring you initial guidance for the core concept.

Playing Flash video using cefsharp or Geckofx

I'm putting together a simple winforms app for playing videos from the web for my kids. I've explored two options so far but I'm having problems with both of them:
cefsharp: Playing videos wasn't a problem, but it would not persist cookies (even with the CachePath set), so I would have to log into the web sites each time. This would not be very user-friendly.
GeckoFX: No matter what site I go to (youtube for example), flash videos will not play. I get a bank section on the page where the video goes. Based on other questions, I tried adding the line "Gecko.GeckoPreferences.Default["extensions.blocklist.enabled"] = false;" right after the initialize statement, but that did not work. I'm running xulrunner-33.0.2 and GeckoFx-Windows-33.0-0.2.
Any ideas on how to get either solution working would be appreciated.
UPDATE:
I found this site https://bitbucket.org/geckofx/geckofx-29.0/issue/14/plugin-flash-not-working-since-xulrunner which stated to turn off the "Visual Studio hosting process" for the project and now YouTube video play with GeckoFX, but no videos play off xfinitytv's site (http://xfinitytv.comcast.net/watch-live-tv/).
A bug has recently been fixed in CefSharp to make this possible. See this issue: https://github.com/cefsharp/CefSharp/issues/843
What should work is:
setting CachePath
set the persist_session_cookies command line argument
after OnContextInitialized, call Cef.SetCookiePath
You'll need to use the latest version 39.0.1 to get access to the OnContextInitialized delegate.

Google Earth API in Silverlight Application

I have been handed over a Silverlight 4 application that uses the Google Earth API. We have an issue with newer versions of Google Earth: In Internet Explorer, the map displays as a white background with the text "ATL 10.00". In other browsers, the background is just white (cannot see any text).
It works with Google Earth version 6.0.3.2197 but not in any version after that.
I have read this thread
- but none of the suggestions there worked. I must note, though, that the JavaScript code for initializing GE in Silverlight is rather complex, but as far as I can se, the initialization of GE is done in the google.setOnLoadCallback function.
It would be nice, if someone knows what exactly the "ATL 10.00" message means.
Any help would be greatly appreciated!
EDIT
Please let me know if I should clarify in further detail.
UPDATE:
The problem was caused by 2 things and probably a combination of the two:
1. The container for the map was added dynamically with JavaScript into another div
2. The container's width and height was set to 0 in order to hide the map.
So, the solution for me was to render the containing div together with the rest of the DOM. In order to "hide" the map, I positioned it absolute beyond the bounds of the screen.
Hope this can guide others to solve similar problems.
ATL in referring to the Active Template Library in Windows. ATL in Windows is a set of template-based C++ classes that let developers create COM objects (rather like MFC and ActiveX).
10.00 here simply refers to version of ATL being used. Seeing it probably means that the COM object (GEPlugin in this case) has not been created or initialised properly in the browser. The blank screen with the version number in the centre is what the plugin looks like before it loads content.
So, it is not really an error message at all - indeed one could say it is really the failure of an error message to appear that you are seeing.
Anyhow, to answer your question in simple terms it means than the version of ATL that was used to create the plugin was version 10.00.
In practical terms it means that the plugin failed to initialise properly for some reason.

How are you integrating help into your WPF application. Any recommendations?

The question says it all really. If you are writing a WPF application, how are you integrating the application help? What is the state of play in mid-2013?
It seems that there is no clear answer to this from an afternoon with a search engine, but several options:
Write your own fancy tooltip based help (but where are you getting your data from?)
Use .CHM files and the Windows Forms help system (seems archaic to me).
Use Microsoft Help Viewer 1.X or Microsoft Help 2.0.
There is some confusion as to which is more recent / approved of by MS. It appear Help Viewer 1.X might be the recommended option over Microsoft Help 2.0. It doesn't help that the names are so similar...
What is the status of 2.0? Should we use it? Was it ever fully deployed?
Use a third-party product to author your help files and link to them somehow - DocToHelp/NetHelp, NetAdvantage on-line help, etc...
Furthermore, what XAML based mark-up / attributes are you using to provide the necessary context? What is the recommended method?
It seems surprising there is no clear path for supporting application based help in WPF.
My current preference is to use a third party help authorizing system to generate HTML based help.
We then use a WebBrowser to display this help as needed. The authoring system we use makes it fairly easy to extract out a single page from the main help (each "topic" is a single HTML file, and can be included with full contents or not as desired).
Granted, this definitely felt like a bit of a nasty hack at first - but once we wrote the basic plumbing (some attached properties for xaml to specify attributes for context location and add behavior to trigger help, etc), it's fairly clean.
One very nice advantage to this approach, however, is a single help system build works perfectly in all contexts - we can include the documentation online, expose it locally for use in a browser, and use it with context from within our application directly.

Silverlight Navigation(PRISM) to show in Browser?

I'm not even sure how to properly ask this question. I'm new to Silverlight and what I'm trying to accomplish is web application that can be referenced using hyperlinks in browser like so:
myapp.com/MaintainUser?UserKey=1
So, I already created modular app with PRISM and using their RegionManager.RequestNavigate and passing URL's here and there. Seems to be working. But browser does not reflect what I'm doing. URL always stays at
myapp.com
I'm not even sure if what I'm doing possible. And if it is, can you point me in correct direction? Or at least terminology.. I thought Navigation will take care of this.
What you are looking for is called deep linking and it's supported by the Silverlight runtime since version 3. However, you should not confuse this with Prism navigation, which is not integrated with the browser.
Here's an quick intro to the standard Silverlight navigation framework.

Resources