Forum Discussion

TestingHobo's avatar
TestingHobo
Contributor
10 years ago

Choose file to upload dialog box


Hi all,



I'm having an issue with my script when choosing where to save or open a file from. As most of you know this will open up a OS style window.



I've managed to get it working 50% of the time by using the following:



Sys.Browser("iexplore").Window("#32770", "Choose File to Upload", 1).Window("ComboBoxEx32", "", 1).Window("ComboBox", "", 1).Window("Edit", "", 1).Keys("c:\\temp\\test.txt");



 but there must be a way to get it working 100% of the time without failing.



I know in Selenium you can SendKeys to the id of the 'Browse' button that will open up the dialog so tried the same with TC eg



  file = Page.FindChildByXPath("//*[@type='file']");


  file.Keys("c:\\temp\\test.txt");


But this does not work in TC. I'm using IE11 but obviously would like to use an xpath style so code is compatible with multiple browsers.


1 Reply

  • HKosova's avatar
    HKosova
    SmartBear Alumni (Retired)
    Hi Richard,



    Use the OpenFile method:



    var dlg = Sys.Browser("iexplore").Window("#32770", "Choose File to Upload");

    dlg.OpenFile("c:\\temp\\test.txt");