Re: file upload stopped working

25 views
Skip to first unread message

darrell

unread,
May 20, 2013, 3:41:30 PM5/20/13
to webd...@googlegroups.com
Is the element with id="input-file-control" visible? I know on many applications I use they have a stylized input for files and the actual INPUT element is hidden. The workflow becomes:

- Click an element which opens a system dialog
- Enter the file information in the system dialog and click Open
- Value from system dialog is passed to the hidden input element

The problem with this workflow is WebDriver does not handle the system dialog properly and the automation hangs. The solution for me was:

- Run javascript to make the hidden input element visible
- Find the input element and sendKeys to it

If I don't have the hidden input element visible this whole thing fails with an ElementNotVisibleException.

The other possibility is that the input element is made visible by the page after page load by javascript code. From a user point of view it looks like the input is always there but in reality it does not appear for the first few milliseconds. Humans are slow enough that it does not matter but WebDriver is so fast that it must delay before trying to access the input element. In these cases you must wait until the input is visible then do the sendKeys, i.e.

    WebElement fileInput = driver.findElement(By.id("input-file-control"));
    // wait for fileInput to be visible
    fileInput.sendKeys(FullPath);

I'll leave it to you to google around for how to wait for the input to be visible.

On Friday, 3 May 2013 06:42:56 UTC-4, Anonyymi646 wrote:
findElement(By.id("input-file-control")).sendKeys(FullPath);
 works just fine with FF16 and Selenium WebDriver version 2.25
but not anymore with 2.28 and newer versions
-> ElementNotVisible exception .
 I also tried with newer FF versions 18.19.20 Any suggestions?

BR, JP
Reply all
Reply to author
Forward
0 new messages