cancel
Showing results for 
Search instead for 
Did you mean: 

How to recognize CSS menu

mazhar555
Contributor

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?

-
Muhammad Mazhar Mahmood
Certified Software Tester (CSTE)
10 REPLIES 10
YMinaev
Staff

RE: How to recognize CSS menu

Hi,



Try refreshing the object tree before accessing the menu. If this doesn't help, explain what you mean by 'not working' in detail.
------
Yuri
TestComplete Customer Care Engineer

Did my reply answer your question? Give Kudos or Accept it as a Solution to help others. ⬇️⬇️⬇️
mazhar555
Contributor

RE: How to recognize CSS menu

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.
-
Muhammad Mazhar Mahmood
Certified Software Tester (CSTE)
YMinaev
Staff

RE: How to recognize CSS menu

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.
------
Yuri
TestComplete Customer Care Engineer

Did my reply answer your question? Give Kudos or Accept it as a Solution to help others. ⬇️⬇️⬇️
mazhar555
Contributor

RE: How to recognize CSS menu

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??
-
Muhammad Mazhar Mahmood
Certified Software Tester (CSTE)
YMinaev
Staff

RE: How to recognize CSS menu

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.
------
Yuri
TestComplete Customer Care Engineer

Did my reply answer your question? Give Kudos or Accept it as a Solution to help others. ⬇️⬇️⬇️
mazhar555
Contributor

RE: How to recognize CSS menu

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


-
Muhammad Mazhar Mahmood
Certified Software Tester (CSTE)
mazhar555
Contributor

RE: How to recognize CSS menu

Hello...........any solution for my problem???
-
Muhammad Mazhar Mahmood
Certified Software Tester (CSTE)
mazhar555
Contributor

RE: How to recognize CSS menu

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

 


-
Muhammad Mazhar Mahmood
Certified Software Tester (CSTE)
YMinaev
Staff

RE: How to recognize CSS menu

Hi,



It looks like we need to access your page to create an example. So, can you provide us with access to your page?
------
Yuri
TestComplete Customer Care Engineer

Did my reply answer your question? Give Kudos or Accept it as a Solution to help others. ⬇️⬇️⬇️
New Here?
Join us and watch the welcome video:
Announcements
Top Kudoed Authors