I’m trying to test the value of the target of a link (href attribute) in a menu containing submenu. The menu is generated with Angular. The sub-menu appears with onmouseover Event on the main item of the menu.
Here my html code:
The xpath of my link to test (from the submenu) is: /html/body/app-root/ux-layout-app-shell/div/div/ux-layout-nav-bar/div/ux-layout-nav-bar-top-menu/nav/ul/li[6]/ul/li[1]/a
When I tried to do that:
Command: storeattribute
Target: /html/body/app-root/ux-layout-app-shell/div/div/ux-layout-nav-bar/div/ux-layout-nav-bar-top-menu/nav/ul/li[6]/ul/li[1]/a@href
Value: href
I get the message: Element /html/body/app-root/ux-layout-app-shell/div/div/ux-layout-nav-bar/div/ux-layout-nav-bar-top-menu/nav/ul/li[6]/ul/li[1]/a not found
I don’t know how to do for getting the good element of the menu, as there is a sub-menu
Hi @grylion54 , there is the command waitForElementPresent
Nevertheless I saw in the dom that the attribute href of the link is not implemented because the target is executed with Angular when somebody clicks on the link. Any idea for testing that ?
@kazurayam Yes that’s it I move the mouse on the main link of the menu and at this moment the sub-menu appears under the main menu with the links to test.
When I tried to recorder the test with the recorder button, the step of the move is not written.
I suppose Katalon Recorder intentionally avoid generating the actions for “mouse over xxxx” events.
Why?
Let’s imagine that Katalon Recorder is designed to generate steps of all “mouse over xxxx” events. When you start recording and moving the mouse over the page (over the elements xxxx, yyyy, zzzz, …), then you would be surprised to see the tool rapidly generates dozens or hundreds of actions:
“move mouse over xxxx”
“move mouse over yyyy”
“move mouse over zzzz”
…
These recorded actions are useless. I am sure, you would hate them.
Like Kazu said the mouse over action is not recorded because it’ll clutter the test quickly. You can still add a step with the command mouseover manually.
@ThanhTo Thanks I will try to implement that. I have just an additional quetion. I saw that the attribute href of the tag a is not displayed in the DOM. Appartenly it is generated with an event managed by Angular. When the click is done on the item of the menu, the user is redirected to the external link (in a new tab). Is it possible to catch the link before the redirection in order to do the test?