We are in the process of "instrumenting" our SmartClient screen elements/components with ID attributes to be able to target them using Selenium and automate our UI testing.
We were successfully able to locate menu using their ID with the help of scLocator inside Selenium IDE (MenuButton class).
However, we are NOT able to locate menu items using their IDs (MenuItem class "under" a Menu object).
Our app dynamically builds the menu content based on the user's authorities (it changes from user to user). Therefore, it is not possible to use a static position in the menu for our tests.
I attached a few screenshots to illustrate what we do.
#1
In Chrome debugger, have a look in the console: you can see the menu has its ID (meiMenu_promotion). And, inside the MenuButton object, the menu's items all have their own unique IDs (meiMenu_promotionNew, meiMenu_promotionOpen). This has been structured in such a way so that we could navigate the menus.
Selecting the menu works fine in Selenium IDE:
scLocator=//MenuButton[ID="meiMenu_promotion"]/
As a 1st step, this is as expected.
#2
What the menu looks like in the app once it's generated with the above code fragment :
#3
As stated above, Selenium IDE is able to locate the top-menu items with its ID. But, the next click on the menu item does not "register" with the MenuItem's ID.
scLocator instead drills into the menu using a non-reliable structure for our use:
The scLocator expression for the menu item is not reliable at all for us:
We were hoping to be able to use something as simple as:
since we explicitly identified the menu items with IDs.
What are our options to select sub-menu items using ID in Selenium with the help of scLocator ?
PS: I thought about using Selenium's right-click feature to locate the sub-menu, but faced the same problem as reported here (right-click selecting the menu item instead of showing the browser's contextual menu) : http://forums.smartclient.com/forum/...den-menu-items.
Thanks !
SmartClient_v91p_2015-10-28_Pro
Selenium IDE 2.9.0
Firefox 42.0 on Windows 7 Pro
We were successfully able to locate menu using their ID with the help of scLocator inside Selenium IDE (MenuButton class).
However, we are NOT able to locate menu items using their IDs (MenuItem class "under" a Menu object).
Our app dynamically builds the menu content based on the user's authorities (it changes from user to user). Therefore, it is not possible to use a static position in the menu for our tests.
I attached a few screenshots to illustrate what we do.
#1
In Chrome debugger, have a look in the console: you can see the menu has its ID (meiMenu_promotion). And, inside the MenuButton object, the menu's items all have their own unique IDs (meiMenu_promotionNew, meiMenu_promotionOpen). This has been structured in such a way so that we could navigate the menus.
Selecting the menu works fine in Selenium IDE:
scLocator=//MenuButton[ID="meiMenu_promotion"]/
As a 1st step, this is as expected.
#2
What the menu looks like in the app once it's generated with the above code fragment :
#3
As stated above, Selenium IDE is able to locate the top-menu items with its ID. But, the next click on the menu item does not "register" with the MenuItem's ID.
scLocator instead drills into the menu using a non-reliable structure for our use:
The scLocator expression for the menu item is not reliable at all for us:
- Our app must be testable in multiple languages; using the "title" attribute to locate the content is not acceptable.
- As stated above, the content of the menu depends on the user's authorities. What is at position 1 for userA will not necessarily be at position 1 for userB.
We were hoping to be able to use something as simple as:
Code:
scLocator=//MenuItem[ID="meiMenu_promotionOpen"]/
What are our options to select sub-menu items using ID in Selenium with the help of scLocator ?
PS: I thought about using Selenium's right-click feature to locate the sub-menu, but faced the same problem as reported here (right-click selecting the menu item instead of showing the browser's contextual menu) : http://forums.smartclient.com/forum/...den-menu-items.
Thanks !
SmartClient_v91p_2015-10-28_Pro
Selenium IDE 2.9.0
Firefox 42.0 on Windows 7 Pro
Comment