Coded Steps for Folder Browser Dialog

2 posts, 0 answers
  1. Nathan
    Nathan avatar
    1 posts
    Member since:
    Sep 2012

    Posted 27 Nov 2013 Link to this post

    We are trying to select a folder path within a dialog from a coded step for a WPF application.  The dialog is generated from the following code:
    System.Windows.Forms.FolderBrowserDialog dlg = new System.Windows.Forms.FolderBrowserDialog();
    dlg.ShowNewFolderButton = false;
    dlg.SelectedPath = GetDefaultDirectory();
    dlg.ShowDialog()

    Any help would be appreciated!
  2. Rodney
    Admin
    Rodney avatar
    6 posts

    Posted 02 Dec 2013 Link to this post

    Hello Nathan, 

    Try using the following code to open the file dialog and navigate to your target folder. The code navigated to the specified file location and handled the dialog in our demo app. If code doesn't fit your exact scenario or if you have additional questions, please provide a copy of a demo app for us to test against. 

    ArtOfTest.WebAii.Win32.Dialogs.OpenFileDialog ofd = ArtOfTest.WebAii.Win32.Dialogs.OpenFileDialog.CreateOpenFileDialog(ActiveApplication, ArtOfTest.WebAii.Win32.Dialogs.DialogButton.OPEN, @"c:\test");
    Manager.DialogMonitor.AddDialog(ofd);
      
    //Replace with your click step to launch dialog
    app.FindName<Button>("myBtn").User.Click()
     
    ofd.WaitUntilHandled(10000);
    Manager.DialogMonitor.RemoveDialog(ofd);


    Let me know if this helps. 


    Regards,
    Rodney
    Telerik
    Quickly become an expert in Test Studio, check out our new training sessions!
    Test Studio Trainings
Back to Top