HtmlInputFile.Upload doesn't work with Firefox or Chrome, and workarounds do not function.

6 posts, 0 answers
  1. Philip
    Philip avatar
    10 posts
    Member since:
    Sep 2010

    Posted 01 Apr 2013 Link to this post

    Greetings and Salutations,

    I have run into a rather aggravating issue with the framework. When I am dealing with Internet Explorer, the following code is able to invoke the HtmlInputFile control and accomplish the upload:

    // Create the dialog listener
    FileUploadDialog theDialog = new FileUploadDialog(waManager.ActiveBrowser, filePath, DialogButton.OPEN);
    waManager.DialogMonitor.AddDialog(theDialog);
     
    // Start the dialog monitor listening, then give it a chance to "breathe"
    waManager.DialogMonitor.Start();
    waManager.ActiveBrowser.WaitUntilReady();
     
    // Now use the element
    fileUploadControl.Upload(filePath, msecWait);
     
    // Give the browser a moment to collect itself
    waManager.ActiveBrowser.WaitUntilReady();
     
    // Finally, turn the dialog monitor off after all is said and done
    waManager.DialogMonitor.RemoveDialog(theDialog);
    waManager.DialogMonitor.Stop();

    This works both in Windows 7 and Windows Server 2008. The problem comes when I attempt to do the same with Firefox and Chrome. The HtmlInputFile.Upload function does not work in either of these browsers in Windows Server 2008, and does not work in Chrome in Windows 7.

    So I searched the forums here and found a workaround:

    // Create the dialog listener
    FileUploadDialog theDialog = new FileUploadDialog(waManager.ActiveBrowser, filePath, DialogButton.OPEN);
    waManager.DialogMonitor.AddDialog(theDialog);
     
    // Start the dialog monitor listening
    waManager.DialogMonitor.Start();
    waManager.ActiveBrowser.WaitUntilReady();
     
    // Now click the element and handle the dialog
    fileUploadControl.MouseClick(MouseClickType.LeftDoubleClick);
    theDialog.WaitUntilHandled(WAIT_Medium);
     
    // Give the browser a moment to collect itself
    waManager.ActiveBrowser.WaitUntilReady();
     
    // Finally, turn the dialog monitor off after all is said and done
    waManager.DialogMonitor.RemoveDialog(theDialog);
    waManager.DialogMonitor.Stop();
    • The problem becomes now that while Firefox and Chrome both succeed running on Windows 7, they fail to run on Windows Server 2008. And now Internet Explorer won't respond on either version of the operating system.

    I have tried this with the following versions of Telerik Test Framework installed:
    2012.1.719

    • 2012.2.1204
    • 2012.2.1420

    At this point I am at a loss of what to try next.

    Please help.


    P.S. A bit of background:  I am writing automated tests for three browsers: Chrome, Firefox and Internet Explorer. My desktop is a Windows 7 machine and where development occurs. Changes are committed to SCM. The automated tests are downloaded and built by a Windows Server 2008 instance from SCM. With the various versions of the framework I have made sure that I uninstall the previous version from both machines and cleanly installed the new, to make sure I did not run into any issues with version conflicts.

  2. Mario
    Admin
    Mario avatar
    8 posts

    Posted 09 Apr 2013 Link to this post

    Hello Phillip,

    Thank you for contacting Telerik Support. I apologize for the delay in getting back to you on this upload dialog issue. I have successfully tested the sample below against IE/FF/Chrome in Win 7 and Server 2008 R2. It works against a public file upload example, I hope you can model your own code after this:

    Manager.Settings.UnexpectedDialogAction = UnexpectedDialogAction.DoNotHandle;
                 
    Manager.LaunchNewBrowser(BrowserType.Chrome);
    ActiveBrowser.NavigateTo("http://cgi-lib.berkeley.edu/ex/fup.html");
                 
    FileUploadDialog upDlg = new FileUploadDialog(ActiveBrowser, @"FILE PATH", DialogButton.OPEN);
    Manager.DialogMonitor.AddDialog(upDlg);
    Manager.DialogMonitor.Start();
                 
    if(ActiveBrowser.BrowserType == BrowserType.InternetExplore
          {
              Find.ByName<HtmlInputFile>("upfile").MouseClick(MouseClickType.LeftClick, 200, 20);
          }
          else
          {
              Find.ByName<HtmlInputFile>("upfile").MouseClick();
          }
    upDlg.WaitUntilHandled(30000);
                 
    Find.ByAttributes<HtmlInputSubmit>("value=Press").Click();
                 
    ActiveBrowser.WaitForUrl("http://cgi-lib.berkeley.edu/ex/fup.cgi", false, 5000);

    Please let me know whether it helps.

    All the best,
    Mario
    the Telerik team
    Quickly become an expert in Test Studio, check out our new training sessions!
    Test Studio Trainings
  3. Philip
    Philip avatar
    10 posts
    Member since:
    Sep 2010

    Posted 09 Apr 2013 Link to this post

    Short answer: No, that does not work.

    Long answer: No, that does not work, and I have found another forum entry that may be pertinent.

    In This Forum Entry, you state that MouseClick doesn't work on "locked" machines. This is executing on a remote machine, though it is executing on an actual user as opposed to a LocalSystem service (which would preclude it from interacting with the desktop). To test this out I set the remote process to run on my own machine (so it runs on my machine as a remote process with my credentials, and I am an administrator of my own computer). Sure enough, the code does not work on the VERY SAME MACHINE when run by the remote process on my machine as my user; yet when I run it directly (without handing it to the automation system) it works just fine.

    Which brings the issue back full circle. As has been stated, Manager.ActiveBrowser.Actions.Click(target_element) doesn't work to invoke HtmlInputFile controls. As has also been stated, HtmlInputFile.Upload only seems to work with Internet Explorer. Given these two constraints, how do I move forward from here? Are there any plans to fix the HtmlInputFile control so that it works with all browsers? Are there any plans to implement double-click functionality for the Manager.ActiveBrowser.Actions?
  4. Mario
    Admin
    Mario avatar
    8 posts

    Posted 15 Apr 2013 Link to this post

    Hi Phillip,

    Indeed, using a MouseClick or any other action which would require you to move the mouse or send key strokes requires an "unlocked" desktop. Please read more about this limitation here in our documentation and ensure your setup also meets all of the other listed conditions.

    Please also confirm these additional security configuration options for IE in Windows Server 2008 as well as the required UAC settings. A configuration which is not constrained by the "locked" machine limitation is key to moving on and handling each situation correctly.

    Unfortunately we are not experts at dealing with system configurations which execute tests as part of a service or process. However we can certainly advise you on any issues with a locally executed test. Do I understand your response correctly in that the upload dialogs are handled correctly when run directly (locally)?

    Greetings,
    Mario
    the Telerik team
    Quickly become an expert in Test Studio, check out our new training sessions!
    Test Studio Trainings
  5. Philip
    Philip avatar
    10 posts
    Member since:
    Sep 2010

    Posted 02 May 2013 Link to this post

    Mario,

    With respect to the Upload Dialogs being handled correctly when being run directly (locally), the answer is yes. They are invoked and handled, whereas when they are run by the automation (remotely / via service / etc) the dialogs never appear and the tests hang and die by timing out. I did confirm both settings were correct before reconfirming the issue. Which seems like a constraint of the plug-ins (Chrome & Firefox) and thus it doesn't affect Internet Explorer (which doesn't need one).

    What other information might we provide each other to help move forward?

    ~ Philip

    P.S. That's Philip with a single 'l', by the way...
  6. Mario
    Admin
    Mario avatar
    8 posts

    Posted 08 May 2013 Link to this post

    Hi Philip,

    My apologies for the spelling error.

    As far as moving forward, if it would be reasonable I suggest providing us with a sample project we can use to bring our test environments as close as possible to reproduce the problem.

    Greetings,
    Mario
    the Telerik team
    Quickly become an expert in Test Studio, check out our new training sessions!
    Test Studio Trainings
Back to Top