Re: [Dev] Sending keys to invisible UI element in Selenium

2016-06-21 Thread Megala Uthayakumar
Hi,

After setting the display of the file element to block it worked.

((JavascriptExecutor) webDriver).executeScript("document.getElementById('
selected-file').style.display=*'block''';*");

Thanks Rasika for offline suggestions.

Thanks.

Regards,
Megala

On Wed, Jun 22, 2016 at 11:04 AM, Megala Uthayakumar 
wrote:

> 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  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 
>> 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".
>>>
>>> 
>>> 
>>> >> "selected-file" name="selected-file">
>>> 
>>> 
>>> 
>>> <%= i18n.localize("browse")%>
>>> 
>>> 
>>> 
>>> >> type="button" title="Upload">
>>> 
>>> <%= i18n.localize("upload")%>
>>> 
>>> 
>>> 
>>>
>>>  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
>>> Dev@wso2.org
>>> http://wso2.org/cgi-bin/mailman/listinfo/dev
>>>
>>>
>>
>>
>> --
>> With Regards,
>>
>> *Rasika Perera*
>> Software Engineer
>> M: +94 71 680 9060 E: rasi...@wso2.com
>> LinkedIn: http://lk.linkedin.com/in/rasika90
>>
>> WSO2 Inc. www.wso2.com
>> lean.enterprise.middleware
>>
>
>
>
> --
> Megala Uthayakumar
>
> Software Engineer
> Mobile : 0779967122
>



-- 
Megala Uthayakumar

Software Engineer
Mobile : 0779967122
___
Dev mailing list
Dev@wso2.org
http://wso2.org/cgi-bin/mailman/listinfo/dev


Re: [Dev] Sending keys to invisible UI element in Selenium

2016-06-21 Thread Megala Uthayakumar
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  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 
> 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".
>>
>> 
>> 
>> > "selected-file" name="selected-file">
>> 
>> 
>> 
>> <%= i18n.localize("browse")%>
>> 
>> 
>> 
>> > type="button" title="Upload">
>> 
>> <%= i18n.localize("upload")%>
>> 
>> 
>> 
>>
>>  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
>> Dev@wso2.org
>> http://wso2.org/cgi-bin/mailman/listinfo/dev
>>
>>
>
>
> --
> With Regards,
>
> *Rasika Perera*
> Software Engineer
> M: +94 71 680 9060 E: rasi...@wso2.com
> LinkedIn: http://lk.linkedin.com/in/rasika90
>
> WSO2 Inc. www.wso2.com
> lean.enterprise.middleware
>



-- 
Megala Uthayakumar

Software Engineer
Mobile : 0779967122
___
Dev mailing list
Dev@wso2.org
http://wso2.org/cgi-bin/mailman/listinfo/dev


Re: [Dev] Sending keys to invisible UI element in Selenium

2016-06-21 Thread Rasika Perera
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  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".
>
> 
> 
>  "selected-file" name="selected-file">
> 
> 
> 
> <%= i18n.localize("browse")%>
> 
> 
> 
>  type="button" title="Upload">
> 
> <%= i18n.localize("upload")%>
> 
> 
> 
>
>  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
> Dev@wso2.org
> http://wso2.org/cgi-bin/mailman/listinfo/dev
>
>


-- 
With Regards,

*Rasika Perera*
Software Engineer
M: +94 71 680 9060 E: rasi...@wso2.com
LinkedIn: http://lk.linkedin.com/in/rasika90

WSO2 Inc. www.wso2.com
lean.enterprise.middleware
___
Dev mailing list
Dev@wso2.org
http://wso2.org/cgi-bin/mailman/listinfo/dev


[Dev] Sending keys to invisible UI element in Selenium

2016-06-21 Thread Megala Uthayakumar
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".







<%= i18n.localize("browse")%>





<%= i18n.localize("upload")%>




 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
Dev@wso2.org
http://wso2.org/cgi-bin/mailman/listinfo/dev