Page 1 of 2 12 LastLast
Results 1 to 10 of 18

Thread: Selenium and File Upload Field

  1. #1
    Sencha Premium User danguba's Avatar
    Join Date
    Feb 2009
    Location
    Kragujevac, Serbia
    Posts
    434

    Question [SOLVED] - Selenium and File Upload Field

    Hi everyone.
    I have a problem with automatic testing using Selenium IDE. I need to upload a file but Selenium seams unable to perform click on browse button. Using http://www.extjs.com/deploy/dev/exam...le-upload.html I can focus browse button but firing selenium click or clickOn event don't produce anything. Am I doing something wrong or is this some Selenium IDE limitation? Any help will be appreciated
    Last edited by danguba; 20 May 2010 at 2:51 AM. Reason: Solved
    All Best
    ---
    Željko Mitrović
    http://skitanja.blogspot.com/

    "Always code as if the guy who ends up maintaining your code will be a violent psychopath who knows where you live." Martin Golding

  2. #2
    Sencha User Condor's Avatar
    Join Date
    Mar 2007
    Location
    The Netherlands
    Posts
    24,245

    Default

    I always thought it was a limitation of browsers, but it seems that somebody actually found a way to bypass the security restriction in Firefox.

  3. #3
    Sencha Premium User danguba's Avatar
    Join Date
    Feb 2009
    Location
    Kragujevac, Serbia
    Posts
    434

    Default

    Finally solved it. It looks like Ext is masking regular upload field with its own. So by selecting the original and then using Selenium type to enter absolute path to file everything works.
    All Best
    ---
    Željko Mitrović
    http://skitanja.blogspot.com/

    "Always code as if the guy who ends up maintaining your code will be a violent psychopath who knows where you live." Martin Golding

  4. #4

    Default tell us how to click on browse button to upload a file.

    Hi danguba,
    can u please paste the code of how to click on browse button. Because i am also unable to click on Browse button in my web application. I tried lot of methods but could not reach to solution.
    It would be great help if you will explain in detail.

  5. #5
    Sencha Premium User danguba's Avatar
    Join Date
    Feb 2009
    Location
    Kragujevac, Serbia
    Posts
    434

    Default

    Hi kashinath.
    U don't actually have to click browse button at all. Instead U just type absolute path to file in regular upload field that is hidden behind ExtJs upload field. If U need details Ill have to check them with my Selenium test team on Monday because this was like 10 months ago and I only help them to locate the field. I hope Monday is not too late 4 U
    All Best
    ---
    Željko Mitrović
    http://skitanja.blogspot.com/

    "Always code as if the guy who ends up maintaining your code will be a violent psychopath who knows where you live." Martin Golding

  6. #6
    Sencha Premium User danguba's Avatar
    Join Date
    Feb 2009
    Location
    Kragujevac, Serbia
    Posts
    434

    Default

    Hi kashinath,
    I talked to Selenium team and here are the results.
    Since we always have only one upload field they R using these two locators when they need to find field
    css locator css=input[name=file]
    xpath locator //input[@name='file']

    Here is a firebug screenshot that can help U better understand the problem

    selenium.png

    So selected input field is the hidden one U need. Just type in absolute address to file in it.
    Input field above it is ExtJs input field and the table below is browse button.
    I hope this makes it easier to understand
    All Best
    ---
    Željko Mitrović
    http://skitanja.blogspot.com/

    "Always code as if the guy who ends up maintaining your code will be a violent psychopath who knows where you live." Martin Golding

  7. #7

    Default

    Thanks danguba, I used XPather to track down my input id, which was:

    /input[@id='ext-comp-1043']

    then I added the following command:

    Command: type
    Target: //input[contains(@id, 'comp')]
    Value: C:\\Users\\path\\test.txt

    Ext JS is proving somewhat complicated to test with Selenium, but I've managed to come up with some workarounds.
    Last edited by ethan.thomason; 3 May 2011 at 7:49 AM. Reason: original solution did not work

  8. #8
    Sencha Premium User danguba's Avatar
    Join Date
    Feb 2009
    Location
    Kragujevac, Serbia
    Posts
    434

    Default

    I just hope Sencha team will decide to release VisualQA for public so we won't have to use selenium workarounds anymore
    All Best
    ---
    Željko Mitrović
    http://skitanja.blogspot.com/

    "Always code as if the guy who ends up maintaining your code will be a violent psychopath who knows where you live." Martin Golding

  9. #9

    Default

    But then my past week's worth of work has been wasted!

  10. #10
    Sencha Premium User danguba's Avatar
    Join Date
    Feb 2009
    Location
    Kragujevac, Serbia
    Posts
    434

    Default

    ROFL
    All Best
    ---
    Željko Mitrović
    http://skitanja.blogspot.com/

    "Always code as if the guy who ends up maintaining your code will be a violent psychopath who knows where you live." Martin Golding

Page 1 of 2 12 LastLast

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •