Developer forum

Forum » Feature requests » NavigationViewModel property or alternative?

NavigationViewModel property or alternative?

Nuno Aguiar Dynamicweb Employee
Nuno Aguiar
Reply

Hi,

 

We are implementing automated QA testing (in Swift) and we're missing one key feature to optimize the process, and that is related to navigation.

 

Currently we need to do things like this (1 example out of many) looking for specific menu items.

  • var cart_menu_item = "#Navigation_Page_Desktop_221_1867";

 

We can't rely on XPath because there may be in different locations. We can't rely on text, because there may be different languages and/or be translated.

 

My idea was to change the Swift Navigation templates to expose the NavigationTag as an attribute or (dummy) css class, and that way getting to the cart page would always be same selector for all of our projects. i.e.

  • var cart_menu_item = "#Cart-page";
    OR
  • var cart_menu_item = ".swift_cart-menu-item";

 

Currently the NavigationViewModel does not have a property exposing the NavigationTag, which to me seems to be the best solution. Can that be added? Or would it make sense to find another solution?

 

Best Regards,

Nuno Aguiar


Replies

 
Nicolai Pedersen Dynamicweb Employee
Nicolai Pedersen
Reply

Maybe you want to coordinate with team Swift - they are also adding IDs for testing purposes.

The viewmodels should be just viewmodels - containing the data that is needed to render. I am not fan of adding all kinds of other stuff like settings. When the NavigationTreeViewModel is created, you pass in some settings - one of those is the navigationtag that you put on settings. You could add the navigation tag to the NavigationSettings.Attributes property instead.

 
Nuno Aguiar Dynamicweb Employee
Nuno Aguiar
Reply

Hi Nicolai,

 

Thanks, I'll work with them on it. And I already identified the menus using NavigationSettings.Parameters["my-custom-attribute"] and giving it a name, that got me most of the way there, as I can now identify the menus in a better way.

 

I still have an issue getting, for example, to the Order History (aka "My Orders") page.

  • It's part of a menu - not a root of one
  • The IDs can be different per environment / project - (that's what I want to minimize)
  • When rendering the navigation nodes I "could" instantiate the page and see if there's a NavigationTag and/or something else that helps me identify that particular page id (regardless of language or environment) - but that does not seem very performant, if I'm doing that for every node.
    • But I agree with you that putting this data in the navigationTreeViewModel seems wrong

 

I'll see if I can come up with something, preventing us from doing too much re-work for automated QA testing across projects. Maybe the fact that we always start with a Swift database ensures the IDs would be the same (unless somebody deletes and recreates some of these pages). In either case, thank you for brainstorming with me.

 

Best Regards,

Nuno Aguiar

 
Nuno Aguiar Dynamicweb Employee
Nuno Aguiar
Reply

Hi Nicolai,

 

I discussed this with the Swift team and we haven't come up with a better option other than the NavigationTag.

 

So we still need some solution for this. The goal is to easilly identify specific menu items (i.e. "My Orders" or "Create new account") using a javascript queryselector (or css selector), so that we could pinpoint a particular page from the markup.

 

It's easy enough to use the pageId, but the problem is that it's not consistent across languages nor across environments (or projects for that matter).

 

Currently the "NavigationTag" does what's needed, which is to identify a particular page regardless of language and even environment/project, and I understand it's not unique nor required.

 

I am open to another solution, even if it only comes in DW10, as long as we can do this.

 

Let me know what you think.

 

Best Regards,

Nuno Aguiar