Two potential solutions

1) ask the developer what action unhides the element so that a normal user 
can interact with it.. e.g. mouseover?     Execute that action first, then 
set the value

2) use execute_script to execute some jquery or other JS code to change the 
style on that element so that it is displayed,  then interact with it.

3) use image based approach such as Sikuli, or RAutomation to automate the 
picking of the file via the UI... 

um ok, so that's three potential solutions (I thought of another while 
writing this)

To the extent you can succeed with either of the above, and that "force 
user to set the image manually, without JS script" is an actual 
requirement, file a bug that they have not prevented the user from doing 
so. In that case, prepare to enjoy outsmarting your developer in the 'arms 
race' you have just declared, because trust me, if your app can run JS to 
do it's stuff, YOU can run JS against it to over-ride anything it's doing, 
it's pretty much impossible for them to prevent #2 above Might require some 
headscratching, but (especially if you can point us at your site) lots of 
folks here love a challenge and might be willing to assist. Also if you 
have to resort to 3 that is STILL automating, and anything you can do, the 
dedicated end user could do as well.. 

Note that I always presume that someone out to do something I don't want 
them to (screen scraping, automating access to my site, trying to hack into 
my site) is at least as smart as I am, or has access to friends that are. 
So if I can do it, they can do it. For your site to be proof against 
automation, YOU have to be completely unable to test it with automation, or 
that requirement has not been met.

Before starting off on the arms race, I'd suggest you discuss with your 
pm/po what has more value: preventing the end user (and thus your automated 
tests) from interacting with the control, or making the code easily 
testable via automation?

On Monday, April 15, 2013 12:09:15 PM UTC-7, Karoline Leite wrote:
>
> Hi guys, 
>
> This way not works to me.
>
> I found the probably problem... The page has a CSS generated by a plugin. 
> And this CSS "hides" the input element, so I can't interact with him.
> The page's developer says that solution is a way to force user to set the 
> image manually, without JS script by example...
>
> *Any idea to automate this test? *
>
> I'm thinking to open a dialog box, drag and drop the image on div or on 
> form... Hope it works!
> To better 
> explain I attached here an image of my page... You can see that INPUT 
> doesn't appear directly, it's hidden on highlights area. The user's page 
> need CLICK in this area to open a dialog box OR drag and drop images to 
> there. As I can't interact with this element to click, I'm trying to open 
> directly the dialog
>
> Thanks,
> Karol
>
> On Monday, April 15, 2013 12:07:40 PM UTC-3, Karoline Leite wrote:
>>
>> Hi !
>>
>> I'm trying to use an INPUT FILE, but I'm receiving error like "unable to 
>> locate {:name=>"original", :tag_name=>"input", :type=>"file"} "
>>
>> My page has an DIV with an FORM, and the FORM has an INPUT FILE element. 
>> The input file has an attribute "MULTIPLE"... 
>>
>> I'm trying:
>>
>> *@browser.div(:class, "ui-dialog ui-widget ui-widget-content 
>> ui-corner-all ").form(:id, "file_upload").file_field(:name, 
>> "original").when_present.set my_image*
>> *
>> *
>> This way, I can't find the element... 
>>
>> I tried, just testing, the both codes and the STEP pass:
>>
>> *@browser.div(:class, "ui-dialog ui-widget ui-widget-content 
>> ui-corner-all ").when_present.click*
>> *
>> *
>> *@browser.div(:class, "ui-dialog ui-widget ui-widget-content 
>> ui-corner-all ").form(:id, "file_upload").when_present.click*
>> *
>> *
>> So, watir finds the DIV and the FORM, but can't find the input file... 
>> I'm thinking the problem is the attribute *multiple *
>> *
>> *
>>
>> How do I set this input file ?
>>
>>
>> The page code:
>>
>> <div style="display: block; z-index: 1002; outline: 0px; height: auto; 
>>>> width: 500px; top: 144px; left: 426px;" class="ui-dialog ui-widget 
>>>> ui-widget-content ui-corner-all " tabindex="-1" role="dialog" 
>>>> aria-labelledby="ui-dialog-title-add_media_dialog"><div 
>>>> class="ui-dialog-titlebar ui-widget-header ui-corner-all 
>>>> ui-helper-clearfix"><span class="ui-dialog-title" 
>>>> id="ui-dialog-title-add_media_dialog"><span class="title">Adicionar 
>>>> imagens</span></span><a href="#" class="ui-dialog-titlebar-close 
>>>> ui-corner-all" role="button"><span class="ui-icon 
>>>> ui-icon-closethick">close</span></a></div><div id="add_media_dialog" 
>>>> style="display: block; width: auto; min-height: 114px; height: auto;" 
>>>> class="ui-dialog-content ui-widget-content">
>>>
>>> <div class="main upload-form clearfix" style="">
>>>
>>>                               <form action="/data_entry/imagens/upload" 
>>>> enctype="multipart/form-data" id="file_upload" method="post" 
>>>> class="file_upload"><div style="margin:0;padding:0;display:inline"><input 
>>>> name="authenticity_token" type="hidden" 
>>>> value="jyzTEwkkJt3MjDn7O5IS+EY1gmuayRiBpDtZXumS4TA="></div>
>>>
>>> *<input multiple="multiple" name="original" type="file">*
>>>
>>> <div class="dropzone">Arraste seus arquivos de imagem nesta área ou 
>>>> clique para escolher os arquivos</div>
>>>
>>>                               </form>
>>>
>>> <div id="files">
>>>
>>> <div class="uploaded"></div>
>>>
>>> <table class="to-upload">
>>>
>>> <tbody></tbody>
>>>
>>> </table>
>>>
>>> </div>
>>>
>>> </div>
>>>
>>> <div class="actions" style="">
>>>
>>> <button class="button default cancel" id="btn_file_upload_cancel">
>>>
>>> <span class="ico"></span>
>>>
>>> Cancelar
>>>
>>> </button>
>>>
>>> <button class="button default play file_upload_start" 
>>>> id="btn_file_upload_start">
>>>
>>> <span class="ico"></span>
>>>
>>> <span begin="Iniciar" class="text" continue="Continuar" pause="Pausar" 
>>>> pausing="Pausando...">Iniciar</span>
>>>
>>> </button>
>>>
>>> <button class="button default ok file_upload_next" 
>>>> id="btn_file_upload_done">
>>>
>>> <span class="ico"></span>
>>>
>>> Pronto
>>>
>>> </button>
>>>
>>> </div>
>>>
>>> </div></div>
>>>
>>>
>>
>> Thanks in advance!
>> Karol  
>>
>

-- 
-- 
Before posting, please read http://watir.com/support. In short: search before 
you ask, be nice.

[email protected]
http://groups.google.com/group/watir-general
[email protected]

--- 
You received this message because you are subscribed to the Google Groups 
"Watir General" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to [email protected].
For more options, visit https://groups.google.com/groups/opt_out.


Reply via email to