2

I'm writing some automation tests using Selenium. I'm on a page that contains kendoUI widgets, such as dropdownlist, textbox, and uploadfile. The way I've been able to deal with the dropdownlist and other elements was to just make calls using the kendo framework.

var x = $('#myId').data('kendoDropDownList')
x.value('1');
x.trigger('change');

Runing the above code allows me to select an item from the dropdownlist.

I'd like to do the same with the upload widget. Thus, the first step was to get the the upload widget reference like this:

var y = $('#myId').data('kendoUpload');

I'fd like to know which how do I open the programatically the file explorer to select a file?

Thanks for helping.

Richard77
  • 20,343
  • 46
  • 150
  • 252
  • http://stackoverflow.com/a/28716332/2074346 is this ur are looking for ? – Kishore Sahasranaman Oct 16 '15 at 16:23
  • That can be a good start. However, the problem with `Kendo wigdets` is that they don't rely on their own library to perform tasks. After struggling to select value using just simple methods, such as click, I leard the hard way that I need first to reference kendo widget then use methods from their library to make things work. – Richard77 Oct 16 '15 at 16:34
  • you can get the reference from their web site. http://docs.telerik.com/kendo-ui/api/javascript/ui/upload – Kishore Sahasranaman Oct 16 '15 at 16:42
  • I've read their website. The earliest event that they talk about is "onUpload", which is after the user has already selected the file. But before that, clicking on the button "Select files..." is not doing anything. I've also tried triggering several event manually, such as click, change, using for instance this `.trigger('select')` ...no success. – Richard77 Oct 16 '15 at 20:33
  • that is not a kendo issue , that is a general browser security restriction . see this http://stackoverflow.com/q/793014/2074346 – Kishore Sahasranaman Oct 17 '15 at 03:45

2 Answers2

2

I was able to upload file in the example of Kendo UI at http://demos.telerik.com/kendo-ui/upload/index using the following Selenium IDE code. First we find the select\upload input tag and send location of the file to be uploaded. After that find the submit button and click.

type    | id=files                        | <path>\Desktop\New Text Document.txt
pause   | 3000                            | 
click   | css=input.k-button.k-primary    |

I am not aware about the correct syntax in JQuery but I think you get the idea. Programatically opening the file explorer and then selecting the file cannot be handled by Selenium as Selenium can access only HTML components.

You can click on the Select button using Selenium and then can maybe use APIs like AutoIt or SIKULI to handling the file selection part through the file explorer.

Hope this helps you.

StrikerVillain
  • 3,719
  • 2
  • 24
  • 41
  • 1
    Wow! I'm completely surprised. Usually, Kendo UI widget works when you access their own api. That's why I didn't even try directly selenium. Thanks a lot. I almost gave up. – Richard77 Oct 19 '15 at 18:53
  • 1
    As per my understanding... Any widgets/app based on HTML which renders in a browser will have html source code and we can use this in Selenium... So while considering using Selenium I just check if HTML code is visible in the developer console – StrikerVillain Oct 20 '15 at 08:35
  • 1
    You are right. The only problem sometimes is that the HTML is a bunch of nested `span` so that it's hard to tell which one is meant to represent the element. – Richard77 Oct 21 '15 at 20:42
  • Yeah .. With these JavaScript, css and jquery based Web page development, finding the right tags is getting very difficult. Even if we manage to find them, their properties might change based on focus, clicks... I miss the good old pure html days when a span was a span, not some genetically (javascript) modified span acting as a button – StrikerVillain Oct 28 '15 at 14:04
0

This has been causing me a headache. To anyone else that encounters this, basically when you're sending the file path send it to the input tag within the div, even though it may not have all the properties of the upload button.

sysofadown3
  • 61
  • 1
  • 5