Accessing gridview items... and drag & drop from desktop & interacting with a browsers file picker

11 views
Skip to first unread message

Vestrit

unread,
Aug 22, 2011, 2:19:16 PM8/22/11
to lebowskifw
Hi all,

Recently had to dive deep into lebowski. (I don't know ruby or rspec
so, that makes it all the more enjoyable woo!)

I'm having trouble accessing the elements inside of a gridView.. in
code they are defined as mainPage.mainPane.view1.contentView.gridView

in gridView there is a contentBinding to an array controller... and
then exampleView and groupExampleView, which are custom views.

I;ve tried [...gridView.contentView].child_views[0], item_views[0]
[...gridView.exampleView] and [..gridView.groupExampleView]
with .child_views and item_views after each of them.. I'm kind of at
a loss for how I'm supposed to get access to those views.. also tried
just [...gridView].child_views & .item_views

Also I have an 'upload picker' that brings up the browsers 'file
picker' is there some way to have lebowski supply the file to the
browser and click that 'ok' button so the 'upload' will start? Is
there a way to simulate drag & drop from outside of the browser into
it? Something like point RSpec at a file on the desktop, then tell
lebowski to drag & drop it onto some view?

Any help would be greatly appreciated

Thanks
Althea

MikeC

unread,
Aug 23, 2011, 1:31:04 PM8/23/11
to lebowskifw
Hey Althea,

Regarding the grid view, you can access its item views just like you
can access items in a list view since the grid view derives directly
from the list view. Item views are accessed using the list view's
item_views method which returns a collection item array. With the
array you can then either directly access an item view via an index or
using a filter. Example:

grid = my_app['path.to.grid.view'] # Will return an list view proxy

# Get the first item view
iv = grid.item_views[0]

# Get the item view that has a content object with guid equal to 9
iv = grid.item_views.first_first({ :guid => 9 })

You can find more examples of how to use the list view proxy by going
to the examples/foundation/spec/sc_controls/specs/views/list_view
folder.

As for uploading files, unfortunately there is no way to use the
native file selector. The same goes for dragging and dropping a file
from the desktop into the browser. Both sit outside of Lebowski's
control. Instead you'll have to supply a string as a path to the file
you'd like to upload.

-Mike

MikeC

unread,
Aug 23, 2011, 1:33:51 PM8/23/11
to lebowskifw
Whoops, made a typo in the previous reply. It's supposed to be
find_first, not first_first :P

-Mike

Vestrit

unread,
Aug 23, 2011, 6:53:46 PM8/23/11
to lebow...@googlegroups.com
Mike,

Thanks for the response, will try this ASAP. Regarding the last issue about 'supplying a string to a path i'd like to upload' thats not outside the realm of possibility, I can maintain a specific 'file system' setup where the lebowski scripts run and say '@file = "/Users/Tester/Files/Fileone.file"', but you make it sound like its possible to pass that info along into lebowski somewhere to say 'lebowski, treat this local file on the file system like it was drag & dropped' or 'lebowski, tell the browser's file picker that this file on the file system is what they wanted to pick'.

What view proxy controls such capability?

MikeC

unread,
Aug 24, 2011, 1:41:16 PM8/24/11
to lebowskifw
Lebowski does not directly expose functionality to help upload files,
but the backing Selenium driver it uses does. You can use the backing
driver's attach_file method to help upload a file. Example:

App = MainApplication.new(...)
App.driver.attach_file <field locator>, <file locator>

The <field locator> is a element locator to the field input (using
either CSS selector or XPath). The <file locator> is a URL pointing to
the specified file. Note that this only works with Firefox. Again,
please note that this is very specific to how the Selenium framework
functions.

-Mike
Reply all
Reply to author
Forward
0 new messages