Setting a domain in Xpath to default to a variable

Ask general questions here.
andy.simpson
Posts: 51
Joined: Fri Jun 22, 2018 8:59 am

Setting a domain in Xpath to default to a variable

Post by andy.simpson » Fri Jan 17, 2020 10:46 am

Hi,


Not really an issue but wondering if anyone here does the same and there is a clever way around it..

So because our automation suite needs to be run against multiple web configurations all of which sit on different domains I have set the domain as a project level variable. This works really well but have noticed it is quite time consuming as whenever we create new repository items whether in spy or using the recorder the domain is hard coded to its actual value, this means that rather than recognizing it as an object that has already present in the repository it creates a new one and is not organised in the repository folders. Is there any of defaulting the recognized domain in Ranorex to be a set variable? It would really save time in terms of duplicate/repository maintenance

Thanks

User avatar
odklizec
Ranorex Guru
Ranorex Guru
Posts: 6036
Joined: Mon Aug 13, 2012 9:54 am
Location: Zilina, Slovakia

Re: Setting a domain in Xpath to default to a variable

Post by odklizec » Fri Jan 17, 2020 10:55 am

Hi,

I personally dropped the idea of using variable at DOM level, because I don't really like the fact one needs to bind every single recording to data connector or parameter. Instead, I'm using multiple @domain attributes with "or" operator. It may not be the cleanest or nicest solution, but it solves both problems ;)
Pavel Kudrys
Ranorex explorer at Descartes Systems

Please add these details to your questions:
  • Ranorex Snapshot. Learn how to create one >here<
  • Ranorex xPath of problematic element(s)
  • Ranorex version
  • OS version
  • HW configuration

andy.simpson
Posts: 51
Joined: Fri Jun 22, 2018 8:59 am

Re: Setting a domain in Xpath to default to a variable

Post by andy.simpson » Fri Jan 17, 2020 11:15 am

The binding itself isn't really an issue, your 'or' does sound good though, could you show an example of one of your xref paths? Would you not need to edit and organise your repository in a similar way if you did it that way anyway?

User avatar
odklizec
Ranorex Guru
Ranorex Guru
Posts: 6036
Joined: Mon Aug 13, 2012 9:54 am
Location: Zilina, Slovakia

Re: Setting a domain in Xpath to default to a variable

Post by odklizec » Fri Jan 17, 2020 11:50 am

Hi,

Here is an example:

Code: Select all

/dom[@domain='domainA' or @domain='domainB' or @domain='domainC' and @visible='true'][@state='complete']
So basically, any new item from domain A, B or C is automatically added to the same DOM, without creating new DOM. Hope this helps?
Pavel Kudrys
Ranorex explorer at Descartes Systems

Please add these details to your questions:
  • Ranorex Snapshot. Learn how to create one >here<
  • Ranorex xPath of problematic element(s)
  • Ranorex version
  • OS version
  • HW configuration

andy.simpson
Posts: 51
Joined: Fri Jun 22, 2018 8:59 am

Re: Setting a domain in Xpath to default to a variable

Post by andy.simpson » Fri Jan 17, 2020 12:13 pm

definitely food for thought thanks :)