Identifying the same element in different domain

Technology specific object identification, supported applications, web technologies, and 3rd party controls.
craig242
Posts: 9
Joined: Mon Jul 29, 2013 3:40 pm

Identifying the same element in different domain

Post by craig242 » Thu Jan 08, 2015 5:34 pm

Hi,

I am currently attempting to automate the login procedure across multiple countries in our pre-prod environment. However the path of each is slightly different as the domain is localized for each country.

E.g.
/dom[@domain='mydomain.france']//input/[#Email]
and
/dom[@domain='mydomain.Germany']//input/[#Email]

The Email field is the same for each domain.

I want to use a CSV file with the URL and logon credentials for each country and run through. However the email element is not identified when the 2nd csv row is used as it falls under a different domain.

Is there a way around this?

Thanks
Craig

krstcs
Ranorex Guru
Posts: 2683
Joined: Tue Feb 07, 2012 4:14 pm
Location: Austin, Texas, USA

Re: Identifying the same element in different domain

Post by krstcs » Thu Jan 08, 2015 5:41 pm

You will need to variablize your domain as well.

The path would be:
/dom[@domain='mydomain.' + $DomainCountry]//input/[#Email]
where DomainCountry is a variable in your repository and you bind it to a value (probably a data column in your CSV).

I actually variablize the whole domain so I can test in any domain.
Shortcuts usually aren't...

craig242
Posts: 9
Joined: Mon Jul 29, 2013 3:40 pm

Re: Identifying the same element in different domain

Post by craig242 » Thu Jan 08, 2015 5:59 pm

Thanks for the reply. I was thinking about making the domain a variable. What would I validate that against though?

I guess I could validate that the domain variable for GB for example matches the URL in my CSV, but it doesn't feel like it's actually ensuring that the domain opens correctly.

krstcs
Ranorex Guru
Posts: 2683
Joined: Tue Feb 07, 2012 4:14 pm
Location: Austin, Texas, USA

Re: Identifying the same element in different domain

Post by krstcs » Thu Jan 08, 2015 6:12 pm

Validating that a particular page opens correctly based on the domain you give would depend on how your system under test is setup. If there is a text field or label somewhere on the page that contains the value, you could use that.

I would say that validating that the domain is the same as the url is probably not a good way to go as sometimes you will have re-directs that would change the domain after the url is entered. But if you know that that isn't the case you could assume that it won't change on you.

You will most likely need to do a bit of string manipulation (cut off bits from things you don't need) in order to get the values to match. The thing to remember is that you set this up to match ONCE on a known GOOD value, and it should work every other time. That is how you validate it. Basically you are trying to pair down the strings so you get the sections you want to compare from each one. Once you have them once, then you know they SHOULD work every other time with other values.


My suggestion would be to separate the URL into domain and page and have each as a separate value. Then, when you need to enter the URL, you concatenate them at run-time.

string url = "http://" + domain + "/" + page;
Shortcuts usually aren't...