Forum Discussion

arijken's avatar
arijken
Occasional Contributor
1 hour ago

Access Form opend with a menuitem

I iterate through submenus in javascript  and when I click a menuitem a Form opens 
On the open form I want to click a toolbar button
this is my script 
        activeForm = Sys.Desktop.ActiveWindow();
        var Toolbar = activeForm.FindChild('Name', "tbFuncties");
        Toolbar.ClickItem("bNew");
but the toolbar.Clickitem does not open the expected window

I'll get the correct activeForm, but not the Toolbar
any help will be appreciated 

3 Replies

  • rraghvani's avatar
    rraghvani
    Icon for Champion Level 3 rankChampion Level 3

    You seem to be referencing the Desktop and not your Application Under Test. 

    Here's example code in accessing Notepad, which is already opened and visible in the Object Browser of TC.

    function Example()
    {
      var notepad = Sys.Process("notepad");
      var wndNotepad = notepad.Window("Notepad");
    
      // Open a file in Notepad
      wndNotepad.MainMenu.Click("File|Open...");
    }

     

    • arijken's avatar
      arijken
      Occasional Contributor

      I know how to open the menu item. When I click on the menu item a window opens. 

      The window contains a grid.  In that window I need to click toolbar buttons which opens a window for editing values 

      I got 3 buttons I want to test
      bNew -> Opens a input form and I Like to add some data en and click the OK button on the form which saves the input

      bEdit -> Opens the same window with data. I want to modify some data and click the OK button on the form 

      bDelete -> Delete the selected row in the grid

      I don't get input window when running my script

      Close the window with the grid and go the the next menu item. 

       

      • rraghvani's avatar
        rraghvani
        Icon for Champion Level 3 rankChampion Level 3

        You need to access your Application Under Test rather than the Desktop (unless your test specifically involves the Desktop).

        I have provided sample code showing how to access the application under test using Notepad as an example, since I don’t know the name of your actual application.