Selenium Silverlight : Object identification is failing - silverlight

My selenium script is returning an error message saying object not found. Can anyone identify where I am going wrong?
Error Message :
com.thoughtworks.selenium.SeleniumException: ERROR: Threw an exception: document.slObject is undefined
The webpage I test is:
http://samples.infragistics.com/sldv/RunSamples.aspx?cn=data-chart#/data-chart/binding-olap-flat-data
The html code of the page is
<div id="silverlightControlHost" style="width: 720px; height: 520px;"><object id="slObject" data="data:application/x-silverlight-2," type="application/x-silverlight-2" width="100%" height="100%"><param name="source" value="/samplesbrowser/ClientBin/Infragistics.Web.SLDV.xap" /><param name="splashscreensource" value="splash.xaml" /><param name="onsourcedownloadprogresschanged" value="onSourceDownloadProgressChanged" /><param name="onsourcedownloadcomplete" value="onSourceDownloadComplete" /><param name="onError" value="onSilverlightError" /><param name="background" value="white" /><param name="minRuntimeVersion" value="4.0.50826.0" /><param name="windowless" value="false" /><param name="autoUpgrade" value="true" /><param name="culture" value="en-US" /><param name="uiculture" value="en-US" /><img id="fallbackImage" src="http://go.microsoft.com/fwlink/?LinkId=161376" alt="Get Microsoft Silverlight" style="border-style: none; width: 100%; height: 100%;" /></object><iframe id="_sl_historyFrame" style="visibility: hidden; height: 0px; width: 0px;border: 0px"></iframe></div>
My selenium code snipped is given below:
#Test
public void testPocAddCustomerHover() throws Exception {
selenium.open(URL);
//Thread.sleep(10000);
silverLightApp = new Silvernium(selenium, "slObject");
selenium.windowMaximize();
assertEquals(100, silverLightApp.actualWidth());
}

I believe that this should be reported on the Issues list here:
http://code.google.com/p/silverlight-selenium/issues/list

Related

Unable to load Silverlight in angular2 when embedded in a component

Current behavior
When embedding and loading Silverlight.xap directly inside an HTML page, it works fine. But when we move same code inside a component, it won't load the Silverlight. DOM in both cases, i.e. embedding and loading through HTML and through component, doesn't show any difference.
Code of Silverlight-app.Component.HTML Page
When we load this page directly, i.e. localhost/OurApp/Silverlight-app.Component.HTML, silverlight content gets loaded and it works fine. But when we open index.html in browser (which is main component of our angular2 and Silverlight-app.Component.HTML page is child component of index.html), it don't load silverlight content.
<section>
<div>
<object id="silverlightControlHost" data="data:application/x-silverlight-2," type="application/x-silverlight-2"
width="100%" height="100%" style="min-height: 100%; height: 1000px">
<param name="source" value="clientbin/SilverlightApp.xap"/>
<param name="onError" value="onSilverlightError" />
<param name="background" value="white" />
<param name="minRuntimeVersion" value="5.0.61118.0" />
<param name="autoUpgrade" value="true" />
<param name="Windowless" value="true" />
<a href="http://go.microsoft.com/fwlink/?LinkID=149156&v=5.0.61118.0" style="text-decoration: none">
<img src="images/slmedallion.png" alt="Get Microsoft Silverlight" style="border-style: none" />
</a>
</object>
<iframe id="_sl_historyFrame" style="visibility: hidden; height: 0px; width: 0px;
border: 0px"></iframe>
<iframe id="desktop" style="visibility: hidden; height: 0px; width: 0px; border: 0px"></iframe>
</div>
</section>
Expected/desired behavior
Embedding and loading Silverlight component should have same behavior irrespective of loading through HTML or through component.
What is the motivation / use case for changing the behavior?
We are migrating our Silverlight application to Angular2. As complete migration will take months, we are keeping some of the silverlight modules as well.
Images for better understanding of the issue
this example does exactly what you need :)
https://github.com/lohiarahul/Angular2-Silverlight-Starter

Create Silverlight control with JavaScript, but maintain navigation

I have a number of Silverlight apps hosted in an ASP.Net Web Forms Application based on the Navigation Application template. My company has upgraded to IE11 and we are now experiencing the "White Screen of Death" on browser refreshes and after using the Back button. A lot of searching has me believing that the only way to solve the WSOD is to replace the object tag that I'm using with JavaScript to load it during the onload event of the html body. While it does appear to fix the WSOD, when I navigate to other pages, the url in the browser does not update, therefore the Back button navigates to the previous web page (not Silverlight page). It appears the the generated html tag differs a bit - possibly most significantly by the "application/x-silverlight" vs. "application/x-silverlight-2" - I did note that the Silverlight.js file does contain the "-2", so I'm not sure why the output does not use it.
Has anyone dealt with this before and come up with a workaround?
Original code:
<div id="silverlightControlHost" style="padding:0px;">
<object id="SilverlightClientControl" data="data:application/x-silverlight-2," type="application/x-silverlight-2" width="100%" height="100%">
<param name="source" value="<%=GetXapLocation()%>"/>
<param name="onError" value="onSilverlightError" />
<param name="background" value="white" />
<param name="minRuntimeVersion" value="4.0.60129.0" />
<param name="autoUpgrade" value="true" />
<param name="initparams" id="initParams" runat="server" value="<%=GetInitialParams()%>"/>
<a href="http://go.microsoft.com/fwlink/?LinkID=149156&v=4.0.60129.0" style="text-decoration:none">
<img src="http://go.microsoft.com/fwlink/?LinkId=161376" alt="Get Microsoft Silverlight" style="border-style:none"/>
</a>
</object>
<iframe id="_sl_historyFrame" style="visibility:hidden;height:0px;width:0px;border:0px"></iframe>
</div>
Updated JavaScript version (function called in onload event of body tag):
function createSL() {
Silverlight.createObjectEx({
source: "<%=GetXapLocation()%>",
parentElement: document.getElementById("silverlightControlHost"),
id: "SilverlightClientControl",
properties: {
background: "white",
version: "4.0.60129.0",
height: "100%",
width: "100%"
},
events: {
onError: onSilverlightError
},
initParams: "<%=GetInitialParams()%>"
});
}
html generated by object tag:
<object width="100%" height="100%" id="SilverlightClientControl" data="data:application/x-oleobject;base64,***long string of characters***"
type="application/x-silverlight-2">
<param name="source" value="/ClientBin/TicketMaintenance.xap?9/24/2015 3:51:25 PM">
<param name="onError" value="onSilverlightError">
<param name="background" value="white">
<param name="minRuntimeVersion" value="4.0.60129.0">
<param name="autoUpgrade" value="true">
<param id="initParams" name="initparams" value="MATaxFreeStartDate=8/15/2015, MATaxFreeEndDate=8/16/2015">
<a style="text-decoration: none;" href="http://go.microsoft.com/fwlink/?LinkID=149156&v=4.0.60129.0">
<img style="" alt="Get Microsoft Silverlight" src="http://go.microsoft.com/fwlink/?LinkId=161376">
</a>
</object>
html generated by the JavaScript:
<object width="100%" height="100%" id="SilverlightClientControl" data="data:application/x-oleobject;base64,***long string of characters***"
type="application/x-silverlight">
<param name="background" value="white">
<param name="source" value="/ClientBin/TicketMaintenance.xap?9/24/2015 3:51:25 PM">
<param name="initParams" value="MATaxFreeStartDate=8/15/2015, MATaxFreeEndDate=8/16/2015">
<param name="onError" value="__slEvent0">
</object>

Silverlight object overflow in IE11

The below code we are using for silver light image display in a div. It's working fine in IE8. But we have an issue with IE11. The image overlapping from the parent div it's not coming inside the div. Can any one fix this issue?
<div id="imgDiv" class="divBrd" style="width: 600px; height: 247px; overflow: auto;">
<div id="tr2">
<div id="divImage" onclick="clipimage(this);" style="overflow: hidden; width: 790px; height: 250px;">
<object type="application/x-silverlight" data="data:application/x-silverlight," id="divImageID" width="780" height="250px">
<param name="background" value="#ffffff">
<param name="Stretch" value="Fill">
<param name="source" value="../ClientBin/ImageHand.xap?v=7af70000-adb3-4167-b945-bf67a28a2186">
<param name="initParams" value="PageId=1,SeqNo=3,SubSeqNo=0,Width=780,Height=250,Container=divImage">
<param name="windowless" value="true">
<param name="maxFramerate" value="24">
</object>
</div>
</div>
</div>
Thanks,
Pandiyan

Source property of Silverlight object

<div id="silverlightControlHost" >
<object id="idThObject" data="data:application/x-silverlight," type="application/x-silverlight-2" width="100%" height="100%">
<param name="source" value="ClientBin/MySolution.xap"/>
<!--<param name="source" value="http://www.mysite.com/ClientBin/MySolution.xap"/> **NOT WORK**-->
...
</div>
Hi to ALL !
My Silverlight object exist on sever side in folder and when I try to load it like this : <param name="source" value="http://www.mysite.com/ClientBin/WebSolution.xap" />
This is doesn't work, but it I load this locally :
<param name="source" value="ClientBin/MySolution.xap"/>, it's work fine.
So what can I do to load my *.xap file from server or I don't have any chance to do it ?
Please check that you have added the required mimetypes for silverlight in IIS on the server.
map the following.
.xap application/x-silverlight-app
.xaml application/xaml+xml
.xbap application/x-ms-xbap
I didn't change any values of any type in html code. Visual Studio 2010 create standard template :
<div id="silverlightControlHost" style="font-size: small;color: red;">
<object id="idThObject" data="data:application/x-silverlight," type="application/x-silverlight-2" width="100%" height="100%">
<param name="source" value="ClientBin/WebSolution.xap"/>
<param name="onerror" value="onSilverlightError" />
<param name="background" value="white" />
<param name="minRuntimeVersion" value="3.0.40818.0" />
<param name="autoUpgrade" value="true"
<a href="http://go.microsoft.com/fwlink/?LinkID=149156&v=3.0.40818.0" style="text-decoration: none;">
<img src="http://go.microsoft.com/fwlink/?LinkId=108181" alt="Get Microsoft Silverlight" style="border-style: none"/>
</a>
</object><iframe id='_sl_historyFrame' style='visibility:hidden;height:0;width:0;border:0px'></iframe></div>
Only one point : provider of my site yahoo.com. So by default this guys don't use IIS.
So you think this is problem ? That Apache doesn't know this :
< ...data="data:application/x-silverlight," type="application/x-silverlight-2"/>
look like I have to move to another provider, which support IIS.

Load image dynamically on Silverlight

I have a Silverlight app that has to load an image dynamically, depending on the image name. The approach that im taking right now is passing the image name by query string to the page and passing that as a param to the Silverlight objet tag
This is the query string passed
Response.Redirect("Build.aspx?img=" + this.PictureUploader.PostedFile.FileName;
And I try to pass it to Silverlight like this:
<object id="SilverlightObject" data="data:application/x-silverlight-2," type="application/x-silverlight-2" width="100%" height="100%">
<param name="source" value="Silverlight/iMapsSL.xap"/>
<param name="onError" value="onSilverlightError" />
<param name="background" value="white" />
<param name="minRuntimeVersion" value="3.0.40624.0" />
<param name="autoUpgrade" value="true" />
<param name="image" value="<%# Request.QueryString["img"] %>" />
<a href="http://go.microsoft.com/fwlink/?LinkID=149156&v=3.0.40624.0" style="text-decoration:none">
<img src="http://go.microsoft.com/fwlink/?LinkId=108181" alt="Get Microsoft Silverlight" style="border-style:none"/>
</a>
</object><iframe id="_sl_historyFrame" style="visibility:hidden;height:0px;width:0px;border:0px"></iframe>
in the last param tag with name=image value= Requerst.QueryString
I catch the image inside the Silverlight app like this
private void Application_Startup(object sender, StartupEventArgs e)
{
string pictureName = "";
if (e.InitParams != null && e.InitParams.Count > 0)
{
pictureName = e.InitParams["image"];
this.RootVisual = new MainPage(pictureName);
}
else
{
this.RootVisual = new MainPage();
}
}
And when MainPage starts, I set the image source of the Image control like this
this.Image.Source = new BitmapImage(new Uri(pictureName, UriKind.RelativeOrAbsolute));
But Silverlight loads without an image, any help someone?
You can't set arbitary values to by inventing a param names like "image". InitParams are created by specifying the "initparams" param. The "initparams" value is a comma delimited set of name=value pairs. Hence your code should look like:-
<object id="SilverlightObject" data="data:application/x-silverlight-2," type="application/x-silverlight-2" width="100%" height="100%">
<param name="source" value="Silverlight/iMapsSL.xap"/>
<param name="onError" value="onSilverlightError" />
<param name="background" value="white" />
<param name="minRuntimeVersion" value="3.0.40624.0" />
<param name="autoUpgrade" value="true" />
<param name="initparams" value="image=<%# Request.QueryString["img"] %>" />
<a href="http://go.microsoft.com/fwlink/?LinkID=149156&v=3.0.40624.0" style="text-decoration:none">
<img src="http://go.microsoft.com/fwlink/?LinkId=108181" alt="Get Microsoft Silverlight" style="border-style:none"/>
</a>
</object><iframe id="_sl_historyFrame" style="visibility:hidden;height:0px;width:0px;border:0px"></iframe>

Resources