Forum Discussion

mazhar555's avatar
mazhar555
Contributor
15 years ago

How to recognize CSS menu

Hi, i am facing problem while accessing menu items, while recording i am clicking the menu but TC does not recognize it while playing. I used DblClickR property which is working for one menu but not working for menu next to it. Code is placed for reference.



Call Page.formCtl1.table.cellBgdarkblue.table.cell.table.cellBkg.table.cellBgmenu.tableSubmenu.cellCellOut.textnodeProjectImplementation.DblClickR


This code is working fine but the following code is not working.



Call Page.formCtl1.table.cellBgdarkblue.table.cell.table.cellBkg.table.cellBgmenu.panelProjectreferential.table.cellTxtblue.textnodeProjectReferential.DblClickR



Is there any other way to access CSS Menu?

10 Replies

  • Hi,



    Try refreshing the object tree before accessing the menu. If this doesn't help, explain what you mean by 'not working' in detail.
  • Hi, actualy i want to access menu at 3rd level. I have written a generic routine which will find the menu and click it. The problem with this routine is its working fine if the menu is on 2nd level but if 2nd level menu containes another menu it stops recognizing it.

    Code and menu immage is attacged.
  • Hi,



    Try creating a function which will recursively go through submenus and click the needed item. In each submenu, hover the mouse pointer over the item which will open the next level submenu and so on until the target item appears.
  • Hi, i have tried different methods to identify submenu but no solution. Actually Object Type of each menu is TextNode, TC recognize Menu, Sub Menu and Child Menu but does not click it. If i use property value (ID) then it works fine, but ID is generated on runtime so for first time it works fine after that you cannot access same menu by its ID. So is there any other solution??
  • Hi,



    OK, exactly what have you tried? Creating a function which will recursively walk down the menu hierarchy should be easy, especially if you actually can work with a 2nd level menu as you said in one of your previous posts. The approach to submenus of any depth is the same as to the first submenu.



    As for accessing menu items by ID, this is incorrect. You should use item captions and probably object types.
  • I am using the following code to access menu:




    Public Sub clickMenu(mMenu, sMenu, cMenu, Caption)



    dim p1, page, mobj, sobj, cobj, PropmArray, PropsArray, PropcArray, ValuesmArray, ValuessArray, ValuescArray


     


    Set p1 = Sys.Process("iexplore")


    Set page = p1.Page("*")


     


    PropmArray = CreateVariantArray(0, 1) 'Main Menu Array


    PropsArray = CreateVariantArray(0, 1) 'Sub Menu Array


    PropcArray = CreateVariantArray(0, 1) 'Child Menu Array


    ValuesmArray = CreateVariantArray(0, 1)


    ValuessArray = CreateVariantArray(0, 1)


    ValuescArray = CreateVariantArray(0, 1)


    ' Specifies property names


    PropmArray(0) = "ObjectType"


    PropmArray(1) = "innerText"


    PropsArray(0) = "ObjectType"


    PropsArray(1) = "innerText"


    PropcArray(0) = "ObjectType"


    PropcArray(1) = "innerText"


     


    '**********Assigning values to each array

    ValuesmArray(0) = "TextNode"


    ValuesmArray(1) = mMenu


     


    ValuessArray(0) = "TextNode"


    ValuessArray(1) = sMenu


     


    ValuescArray(0) = "TextNode"


    ValuescArray(1) = cMenu


     


     


    Set mobj = page.Find(PropmArray, ValuesmArray, 20)


    If Not mobj.Exists Then


    Log.Error("Main Menu " + mMenu + " is unavailable")


    Exit Sub


    End If


     


     



    mobj.Click


     


    Log.Message("Main Menu " + mMenu + " was clicked.")


    delay(500)


    '''''''********Click on sub menu


     


    Set sobj = page.Find(PropsArray, ValuessArray, 20)


    If Not sobj.Exists Then


    Log.Error("Sub Menu " + sMenu + " is unavailable")


    Exit Sub


    End If


     


     



    sobj.Click


     


    Log.Message("Sub Menu " + sMenu + " was clicked.")


    Delay(500)


     


    ''*********Clicking Child Menu


    Set cobj = page.Find(PropcArray, ValuescArray, 20)


    If Not cobj.Exists Then


    Log.Error("Child Menu " + cMenu + " is unavailable")


    Exit Sub


    End If


     


     



    cobj.Click


     


    Log.Message("Child Menu " + cMenu + " was clicked.")


    page.Wait


    Call aqObject.CompareProperty(p1.IEFrame(0).WndCaption , 6, Caption, False)



    End Sub


  • Well No solution yet.... i have a modified my script but it will work only if application dont have same menu's in two diferent places.




    Public Sub clickMenu(mMenu, sMenu, cMenu, Caption)


    clickMenu(mMenu, sMenu, cMenu, Caption)

    dim p1, page, mobj, sobj, cobj


     


    'initialize the broswer, page, and current form for testing


    Set p1 = Sys.Process("iexplore")


    Set page = p1.Page("*")


     


     


    page.Refresh


     


    'Try to find the button


    Set mobj = page.NativeWebObject.Find("innerText", mMenu)


    If Not mobj.Exists Then


    Log.Error("Main Menu " + mMenu + " is unavailable")


    Exit Sub


    End If


     


     



     


    'click the link and log it

     



    mobj.Click


    Log.Message("Main Menu " + mMenu + " was clicked.")


    delay(500)


    '''''''********Click on sub menu


    Set sobj = page.NativeWebObject.Find("innerText", sMenu)


    If Not sobj.Exists Then


    Log.Error("Sub Menu " + sMenu + " is unavailable")


    Exit Sub


    End If


     


     



     


    'click the link and log it

     



    sobj.Click


    Log.Message("Sub Menu " + sMenu + " was clicked.")


    delay(500)


     


    ''*********Clicking Child Menu


    If not cMenu = "" then  'In case if there is not child menu, system will only click to sub menu and exit.



    Set cobj = page.NativeWebObject.Find("innerText", cMenu)


    If Not cobj.Exists Then


    Log.Error("Child Menu " + cMenu + " is unavailable")


    Exit Sub


    End If


     


     



     


    'click the link and log it

     



    cobj.Click


    Log.Message("Child Menu " + cMenu + " was clicked.")


    page.Wait


    End If


    'Comparing Page Caption


    Call aqObject.CompareProperty(p1.IEFrame(0).WndCaption , 6, Caption, False)


     



    End Sub

     


  • Hi,



    It looks like we need to access your page to create an example. So, can you provide us with access to your page?
  • Hello, i cannot give you the project link cuz its not on internet. Hoever you can use the following code which has the same problem.




    'Defining Global Veriables



    Dim Page, p

    Sub browserLaunch()


    Call TestedApps.IEXPLORE.Run(-1,false)


    Delay(5000)


    Set p = Sys.Process("iexplore")


    Set page = p.page("*")


    End Sub


    Sub launchURL(url)


    page.toUrl(url)


    page.wait End Sub


    sub callMenuItem(mMenu,sMenu,cMenu)

    dim mobj,sobj,cobj, PropmArray, ValuesmArray


    PropmArray = CreateVariantArray(0, 1)


    ValuesmArray = CreateVariantArray(0, 1)


    PropmArray(0) = "ObjectType"


    PropmArray(1) = "innerText"


    ValuesmArray(0) = "Link"


    ValuesmArray(1) = cMenu


    set mobj = page.NativeWebObject.Find("innerText",mMenu)


    mobj.HoverMouseset sobj = page.NativeWebObject.Find("innerText",sMenu)


    sobj = page.NativeWebObject.Find("innerText",sMenu)

    sobj.HoverMouseset cobj = page.Find(PropmArray,ValuesmArray,20)


    cobj = page.Find(PropmArray,ValuesmArray,20)

    cobj.Click


    page.WaitLog.Message("Link Clicked")



    '''''*******Following code is also not working in some cases**********

    'set cObj = page.NativeWebObject.Find("innerText",cMenu)


    'cobj.Click


    'page.Wait


    'Log.Message("Lick Clicked")



    End Sub


    sub Main()

    call browserLaunch()


    Call launchURL("http://www.cricinfo.com")


    'working for the following


    Call callMenuItem("Features","Regulars","Print Run")


    Delay(2000)


    'Not Working for the following params


    Call callMenuItem("Features","All Time XI","Pakistan")

    End Sub



    Most intresting thing is change the order of calling menu in Main and see result is totaly different:


    sub Main()

    call browserLaunch()


    Call launchURL("http://www.cricinfo.com")


    'working for the following


    Call callMenuItem("Features","All Time XI","Pakistan")


    Delay(2000)


    'Not Working for the following params


    Call callMenuItem("Features","Regulars","Print Run")

    End Sub