How to set file for a silverlight upload button - silverlight

html:
<div id=“file”>
<object data="data:application/x-silverlight-2," type="application/x-silverlight-2">
...
</object>
</div>
I've manage to click the silverlight button using following code:
f = Browser.div(:id => "file")
Browser.driver.action.move_to(f.wd).click.perform
However, when the file upload dialog opens, how can I set the file?
I'm using ChromeDriver.

According to the documentation, watir-webdriver cannot interact with silverlight objects:
Watir will drive web applications that are served up as HTML pages in a web browser. Watir will not work with ActiveX plugin components, Java Applets, Macromedia Flash, or other plugin applications. To determine whether Watir can be used to automate a part of a web application, right click on the object and see if the View Source menu option is available. If you can view the HTML source, that object can be automated using Watir.

Related

SharePoint 2013 - Silverlight WebPart XAP Cache

Good Morning,
I am new to sharepoint but I am pretty salty as far as silverlight goes. I know on a standard silverlight application hosted inside an ASP.NET app you can simply append .xap? here to make sure the xap files does not cache each time. In SharePoint I found only one article that even came close to exphttp://techblog.m-dd.com/index.php/2013/01/25/resolve-sharepoint-silverlight-webpart-caching-problem/. When I trying to Edit the WebPart and Under Application, provide path to .xap I click Configure. I then appent something like this to the end of the xap file: .xap?ver=1.1.1.0002 and recieve the following error in sharepoint: Cannot save all of the property settings for the Web Part. One or more errors have occured.
Any help would be greatly appricated.
Thanks
In my experience I've had a lot more luck by using a Content Editor Web Part and then embedding the tag which then links to the .xap file from there. Essentially you can edit the HTML source of the page by adding such a web part.
In the Content Editor Web Part, select "Edit Source" and paste something similar to this:
<object width="300" height="300"
data="data:application/x-silverlight-2,"
type="application/x-silverlight-2" >
<param name="source" value="/Library/YourSilverlight.xap?v=1"/>
</object>
See embedding Silverlight here: http://tz.nu/1o9pkSk
See more about adding the Content Editor Web Part here: http://tz.nu/1tSCOnJ
Using this approach, you can simply modify the page and edit the CEWP (Content Editor Web Part) and append the querystring behind the .xap to something unique (in my case, perhaps increment it to YourSilverlight.xap?v=2).
As an alternative to all of the above;
I've oftentimes developed my own base web part which hosts Silverlight .xap files, then I'll deploy and add that Web Part instead. I've often built-in the functionality for updated versions into the code so you never have to do that manually, but that's another story.

Auto fill form in Silverlight OOB

I have a Silverlight Out-of-Browser (OOB) application which has a WebBrowser control inside it. Displayed website in inner web browser comes from the different domain than the application xap file. How could I automatically fill form displayed in the inner browser? Preferably directly with Silverlight, or JavaScript.
I have tried to invoke external JavaScript code from silverlight application:
webBrowser.InvokeScript ("eval", "document.getElementById('formField1').value = 'value1';" +
"document.getElementById('formField2').value = 'value2';"+
"document.forms[0].submit();");
Apparently Silverlight limits this functionality due to the security reasons (Cross-site scripting I think).
WebBrowser.InvokeScript
Executes the specified script, which is defined in the currently loaded HTML.
Since my JS code is not loaded in the HTML that is currently displayed in the web browser control I can't use this approach.
Most obvious solution is to modify target website to contain my JS code. But I would like to hear some other options.

SILVERLIGHT. How to download file like from web-site

I want download file from server. I know how to do this using WCF/RIA services. How can I do this like in web site. For example: I click button and It will appear standard dialog browser window to download file.
Use the Hyperlink control and link it to a server-side URL. This is what I've done in my app to avoid the whole generic save file prompt restrictions of the default SL sandbox.

Unable to register silverlight user control in aspx page

I have made a simple silverlight application. Everything is working fine but I am unable to use silverlight user control as my aspx page shows only embedded object code.
I have also tried to register the silverlight control with the following code:
<%# Register Assembly="System.Web.SilverLight" Namespace="System.Web.UI.SilverLightControls" TagPrefix="asp" %>
but it did not work. I want to do this, so that I would able to pass parameter to silverlight control from my aspx page.
How should I register the silverlight user control in my aspx page? I am using silverlight 3.0 version.
The Silverlight server control is no longer supported in version 3.0. You will need to use the object html tag instead. See my answer to a similar question here.

How to embed Silverlight control in blog page?

How can I embed a demonstration applet written in Silverlight within a blog post? Is it possible to do so using any hosted blog engines, or only using a blog engine that I host myself?
I assume that I will need to use the same tags and .js as in a regular (X)HTML page with a SL control. Are there any hosted blog engines that will permit me to enter this? (Is it possible with blogger?)
Does the SL security model mean that the XAP file need to be hosted on the same site as the blog pages itself?
You can host a Silverlight app in HTML using the <object> tag, there is no need for the blog host to understand any of this. There is no server side element to hosting a Silverlight app its a purely client side thing.
<object id="SL" data="data:application/x-silverlight-2," type="application/x-silverlight-2" style="width:400px; height:300px">
<param name="source" value="MySLApp.xap" />
<param name="minRuntimeVersion" value="3.0.40624.0 />
<param name="initParams" value="someParam=value" />
<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" style="border-style: none" alt="Get Microsoft Silverlight" />
</a>
</object>
In this case the Silverlight app "MySLApp.xap" is placed in the same folder as the HTML page using it. However it could be on a different server if you like. However access to the HTML Bridge will be blocked but then if your app is self contained and does not need to communicate with the host page then there is no problem.
I created a Silverlight xap to host hero images OR video in my wordpress theme - I pass the content to it using initparams and custom fields per post.
That way I can use the same xap to host videos with media controls if appropriate or images with cool fade ins/click effects
example image post:
http://www.blackspike.com/site/html/display-google-docs-spreadsheets-in-wordpress
example video post (click vid for controls):
http://www.blackspike.com/site/wpf/hanselmans-babysmash
Both using the same xap!
An easy solution that worked for me is just to use an iFrame. So I published the regular TestPage.html generated by Visual Studio to my web site (along with the .XAP file of course) and then embedded it:
<iframe src="http://www.lostbearlabs.com/sl/Spring001/TestPage.html" frameborder="0" width="400" height="400" scrolling="no" ></iframe>
Using blogger, I discovered this gotcha: Any attempt to make the HTML pretty (e.g. by splitting it into separate lines) causes blogger to insert spurious <br> tags into the output, even if I do my edits using the "Edit HTML" view. So the iFrame tag must all be on a single line!!
You might want to check your host has the required MIME types mapped:
http://learn.iis.net/page.aspx/262/configuring-iis-for-silverlight-applications/
according to this Server 2008 IIS7 should work out of the box but IIS6 may require MIME types adding...
The solution marked as answer above works well if the HTML page and the Silverlight xap file are hosted on the same server.
As this is not possible in most of the cases, as most of the bloggers use either blogger/WordPress. We do not have any way of setting the mime type on these hosting providers.
Here is a good link which explains in detail regarding hosting an Silverlight application in blogger.

Resources