Hi All,

It is because of  WebDriver cant interact with hidden elements[1].

Selenium FAQ page also providing the same solution that Supun has tried out.
Ex:

((JavascriptExecutor)driver).executeScript("arguments[0].style.visibility
= 'visible'; arguments[0].style.height = '1px';
arguments[0].style.width = '1px'; arguments[0].style.opacity = 1",
fileUploadElement);

But we need to clear about whether we can alter the  application [ make a
hidden element visible] during a test.


[1]
https://code.google.com/p/selenium/wiki/FrequentlyAskedQuestions#Q:_Does_WebDriver_support_file_uploads?

Thanks and Best Regards,

Saneth Dharmakeerthi
Senior Software Engineer
WSO2, Inc.
Mobile: +94772325511

On Sat, Dec 13, 2014 at 10:28 AM, Krishantha Samaraweera <
[email protected]> wrote:
>
> Hi Supun,
>
> Can you share a pack to reproduce this behaviour. Please mention the steps
> to follow.
>
> Thanks,
> Krishantha.
>
>
>
> On Sat, Dec 13, 2014 at 8:33 AM, Supun Sethunga <[email protected]> wrote:
>>
>> Hi all,
>>
>> I am writing a test case for a CSV-file uploading function, of a Jaggery
>> page. There is a browse button which allows to browse any file in the file
>> system. Once a file is selected and clicked the 'import' button, file get
>> uploads. Underneath what happens is, once the file is browsed and selected,
>> it gets assigned to a "*<input type ='file' name='dataFile'>* " element.
>> Follow is the html code.
>>
>>                     *<div id="dataSource" class="row">*
>> *                        <div class="cell" > Data Source:</div>*
>> *                        <div class="cell">*
>> *                            <input type="text" id="datasetName"
>> name="datasetName" disabled/>*
>> *                            <input type="button" id="datasetOpen"
>> value="Browse" /> *
>> *                            <span id="datasetNameValidator"></span>*
>> *                        </div>*
>> *                        <input type="file" size="60" name="dataFile"
>> id="**dataFile**"> *
>> *                    </div>*
>> *                    <div id="import" class="row">*
>> *                        <div class="cell"><input type="submit"
>> value="Import"></div> *
>> *                    </div>*
>>
>> I've not been able trigger this using Selenium driver, since once the
>> 'browse' button is clicked, the popup opens is a OS level window, thus
>> selenium driver cannot handle it. As a workaround, tried setting the file
>> path to the *<input type ='file' name='dataFile'> *html element, rather
>> than browsing the file. But again, Selenium driver is unable to set the
>> path to this element as it is an 'hidden' element.
>> (As the offline discussion, if I change the visibility of this file
>> element to 'visible', then the Selenium driver can set the file path to the
>> element, and the import function get triggered correctly.)
>>
>> Any idea on how to trigger such a file uploading with Selenium, or any
>> workaround?
>>
>> Much appreciate any help, as this has become a blocker for writing the
>> rest of the test cases.
>>
>> Thanks
>> Supun
>>
>> --
>> *Supun Sethunga*
>> Software Engineer
>> WSO2, Inc.
>> lean | enterprise | middleware
>> Mobile : +94 716546324
>>
>
>
> --
> Krishantha Samaraweera
> Senior Technical Lead - Test Automation
> Mobile: +94 77 7759918
> WSO2, Inc.; http://wso2.com/
> lean . enterprise . middlewear.
>
_______________________________________________
Dev mailing list
[email protected]
http://wso2.org/cgi-bin/mailman/listinfo/dev

Reply via email to