Hi Rasika,

Thanks for suggestion. I already tried those. But still I am getting the
same error. I doubt it is because of the file-upload-control class in the
the parent div.

Thanks.

Regards,
Megala



On Wed, Jun 22, 2016 at 10:48 AM, Rasika Perera <[email protected]> wrote:

> Hi Megala,
>
> As [1] says, sending keys to a hidden element is a special use case.
> Selenium throws this exception because such that in real scenario user
> isn't entering text into hidden inputs as such. Hence "file input" should
> be treated as a special case. You may also need to enable a File Detector
> if you are uploading to a remote server as in [2].
>
> In provided code sample, It has no inline code to set the element hidden.
> May be external css/js making it hidden.
>
> You may need to make the element visible and apply sendKeys().
>
> ((JavascriptExecutor) webDriver).executeScript("document.getElementById('
> selected-file').style.display='';");
> //.....apply sendKeys()
> ((JavascriptExecutor) webDriver).executeScript("document.getElementById('
> selected-file').style.display='none';");
>
> [1]
> https://github.com/seleniumhq/selenium-google-code-issue-archive/issues/7625
> [2] https://saucelabs.com/resources/articles/selenium-file-upload
>
> Thanks,
> Rasika
>
> On Tue, Jun 21, 2016 at 1:51 PM, Megala Uthayakumar <[email protected]>
> wrote:
>
>> Hi All,
>>
>> I am trying to write a UI test case in selenium which requires to send
>> the keys to invisible file element in UI. In a normal scenario, user
>> selects the file using a file browser and when the user selects a file, the
>> selected file will be automatically passed to that file UI element.
>> Following is the code fragment that is used for this purpose. In this I
>> need to send keys to element with id "selected-file".
>>
>> <div class="input-group input-wrap file-upload-control">
>>     <input type="text" class="form-control" readonly="">
>>     <input type="file" class="form-control" accept=".zip" id = 
>> "selected-file" name="selected-file">
>>     <div class="input-group-btn">
>>         <button class="btn browse" type="button" title="Browse File">
>>             <i class="fw fw-file-browse" aria-hidden="true"></i>
>>             <span class="hidden-xs"><%= i18n.localize("browse")%></span>
>>         </button>
>>     </div>
>>     <div class="input-group-btn">
>>         <button class="btn btn-default btn-primary asset-upload" 
>> type="button" title="Upload">
>>             <i class="fw fw-upload" aria-hidden="true"></i>
>>             <span class="hidden-xs"><%= i18n.localize("upload")%></span>
>>         </button>
>>     </div>
>> </div>
>>
>>  Selenium finds this element but it does not allow to send the keys by 
>> throwing and exception "Element is not currently visible and so may not be 
>> interacted with". How can I write a test case for this scenario?
>>
>> Any helps on this is highly appreciated.
>>
>> Thanks.
>>
>> Regards,
>>
>> Megala
>>
>> Megala Uthayakumar
>>
>> Software Engineer
>> Mobile : 0779967122
>>
>> _______________________________________________
>> Dev mailing list
>> [email protected]
>> http://wso2.org/cgi-bin/mailman/listinfo/dev
>>
>>
>
>
> --
> With Regards,
>
> *Rasika Perera*
> Software Engineer
> M: +94 71 680 9060 E: [email protected]
> LinkedIn: http://lk.linkedin.com/in/rasika90
>
> WSO2 Inc. www.wso2.com
> lean.enterprise.middleware
>



-- 
Megala Uthayakumar

Software Engineer
Mobile : 0779967122
_______________________________________________
Dev mailing list
[email protected]
http://wso2.org/cgi-bin/mailman/listinfo/dev

Reply via email to