Tags, Web aplication and user code

Ask general questions here.
jviana13
Posts: 10
Joined: Wed Apr 21, 2021 2:33 pm

Tags, Web aplication and user code

Post by jviana13 » Wed Apr 21, 2021 3:09 pm

Hello all, I'm new at Ranorex and I need to create a usercode routine to select multiple items on a website.

I have the XPath of each item, and I want to select, and insert text on the items that have that option, and then perform other actions.

the problem that I'm facing is that it seams that I can't assign the XPath to any variable in order to perform CliCK() ou GetValue() ... etc.

I try to use the Selenium "driver" but even that, gives me error. I think this is a easy fix, but I realy do not have the knoledge yet. Also I start C# learming in April and basicly I'm a beginer.

Hope someone could help me.

Regards

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

Re: Tags, Web aplication and user code

Post by odklizec » Wed Apr 21, 2021 8:54 pm

Hi,

At first, please create a Ranorex snapshot (NOT screenshot) of the UI you are working with and post it here (zipped please). Then add some example xpaths and ideally, also step-by-step instructions for what you are trying to do.

Without, at very least, Ranorx snapshot, there is not much anyone here can do or suggest. Thanks.
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

jviana13
Posts: 10
Joined: Wed Apr 21, 2021 2:33 pm

Re: Tags, Web aplication and user code

Post by jviana13 » Tue Apr 27, 2021 9:25 am

Ok. So, for example. I have a website, with a certain url, and I am doing some test on it. But for the validation of some instances, I need to aply some logic (C#) and decide witch option select. On the image atached you could see what tipe of options I have.

For the Download users, I have imagine, the follow XPath: "blablablablablablaXPATH\input[@value='Download Users']"

I just simply can't use the repository item option to select this specific button, because, the ID is not unique, there are others equal, but the XPath is unique. I need to find a way to link the XPath with the user code area on Ranorex test environment.

How can I do that? I try to use selenium but or I lack knoledge, more likely, or I can´t use it.

Can someone help?
You do not have the required permissions to view the files attached to this post.

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

Re: Tags, Web aplication and user code

Post by odklizec » Tue Apr 27, 2021 10:11 am

Hi,

Unfortunately, what you've posted is screenshot, not snapshot. Please create and upload a Ranorex snapshot of your AUT, which will help us with creating sample code or providing reasonable suggestion. Thanks.
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

jviana13
Posts: 10
Joined: Wed Apr 21, 2021 2:33 pm

Re: Tags, Web aplication and user code

Post by jviana13 » Tue Apr 27, 2021 10:31 am

I did not know what was that. Thank you.

Unfortunatly I can't do it because is private information of my company. It that will be an issue? Because it's a normal button, it could be anything actually. My question is how I can handle XPaths on ranorex.

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

Re: Tags, Web aplication and user code

Post by odklizec » Tue Apr 27, 2021 11:29 am

Hi,

I'm afraid, that without snapshot I can suggest only some general suggestions.

Basically, if the id of a particular element is not unique, you should use another element (with unique information) as an 'anchor', from which you need (somehow) traverse to the element of your choice relationship operators. It's relative, easy process. Sadly, without knowledge of structure of your GUI, I can't give you any reliable sample. All I can suggest is to thoroughly read Ranorex user guide, especially chapters about xpath construction. And check also these blog posts:
https://www.ranorex.com/blog/automated- ... namic-ids/
https://www.ranorex.com/blog/ranorexpat ... nd-tricks/
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

jviana13
Posts: 10
Joined: Wed Apr 21, 2021 2:33 pm

Re: Tags, Web aplication and user code

Post by jviana13 » Tue Apr 27, 2021 3:32 pm

Ok, so, let me try to simplify it.

I have installed on my Chrome browser the Ranorex tool to extract the XPath from any item(exemple on image attached).

With this, I want to, using the code, create a new item, to then perform a validation, for example.

Code: Select all

RxPath newXPath = "xpath copy from the browser";
bool exists = Validate.Exists(newXPath, 20000, "Check Object '{0}'", false);
I know that it would be esay to just add the item to the repository, and then use it. But first that will only resolve some of my tests, and then I use a lot of items, it became very confuse.

Can you help?
You do not have the required permissions to view the files attached to this post.

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

Re: Tags, Web aplication and user code

Post by odklizec » Tue Apr 27, 2021 3:59 pm

Hi,

I'm afraid, you are trying to overcomplicate things a bit? What you want is definitely possible, but if you are new to Ranorex, you should really stick with repository and recordings modules and then, once you get comfortable, add coded things.

Ranorex is not Selenium and you should really use repository, which makes Ranorex projects easy to edit and grow. Hardcoding xpaths directly in CS files is way to hell, from long-term project perspective.

At next, I would really recommend to use Ranorex Studio tools for generating xpaths, not browser specific tools! Not even Ranorex Selocity tool, which is intended to be used with Selenium and Ranorex WebTestit tool and not Ranorex Studio! The thing is, that Ranorex Studio does not support all xpath keywords and some other aspects of xpath specification. So you should really use Ranorex Studio Spy to generate xpaths and then, if you wish, edit them accordingly. Ranorex will validate your edited xpaths and make sure they are 100% compatible.
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

jviana13
Posts: 10
Joined: Wed Apr 21, 2021 2:33 pm

Re: Tags, Web aplication and user code

Post by jviana13 » Tue Apr 27, 2021 4:09 pm

Yes, that would be perfect but the person I came to replace, have a high level of ranorex coding, and I need to catch up fast.

Image this instead, what can I use on the variable newXPath (code 1)? For example, if I copy the path from the items on ranorex, and create a variable for example (code 2):

Code: Select all

bool exists = Validate.Exists(newXPath, 20000, "Check Object", false);

Code: Select all

(vartypr?) newXPath = path from item on ranorex?

jviana13
Posts: 10
Joined: Wed Apr 21, 2021 2:33 pm

Re: Tags, Web aplication and user code

Post by jviana13 » Tue Apr 27, 2021 4:55 pm

More simple, how can I get the path, from an item on the repository?

Because that could help me understand how the xpath and the RXpath work.

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

Re: Tags, Web aplication and user code

Post by odklizec » Tue Apr 27, 2021 5:52 pm

Hi,

So basically, you can do something like this:

Code: Select all

public void GetXpathFromRepoItemInfo(RepoItemInfo repoElement)
    {
        string xpathFromElement = repoElement.Path.ToString();
     }
Add this method to recording of your choice and simply drag&drop repo element to "repoElement" parameter of above method (in recording table).
Last edited by odklizec on Wed Apr 28, 2021 2:28 pm, edited 1 time in total.
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

jviana13
Posts: 10
Joined: Wed Apr 21, 2021 2:33 pm

Re: Tags, Web aplication and user code

Post by jviana13 » Wed Apr 28, 2021 2:25 pm

Hy,

I try to use it, but I got the follow code compile error:
Non-invocable member 'RepoItemInfo.Path' cannot be used like a method. (CS1955)


Do you know what I am doing wrong?

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

Re: Tags, Web aplication and user code

Post by odklizec » Wed Apr 28, 2021 2:28 pm

Hi,

Sorry, my mistake. Get the updated code ;)
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

jviana13
Posts: 10
Joined: Wed Apr 21, 2021 2:33 pm

Re: Tags, Web aplication and user code

Post by jviana13 » Wed Apr 28, 2021 3:08 pm

Hy,

Yes, the code works just fine. But I have an issue now. the code bellow, only the one I use the "repoElement" works, I can´t figure out why when I use the path fails the validation. The first one work, the second one no.

Code: Select all

public void GetXpathFromRepoItemInfo(RepoItemInfo repoElement){
        	string xpathFromElement = repoElement.Path.ToString();
        	bool exists = Validate.Exists(repoElement, "Check Object '{0}'", false);
}

Code: Select all

public void GetXpathFromRepoItemInfo(RepoItemInfo repoElement){
        	string xpathFromElement = repoElement.Path.ToString();
        	bool exists = Validate.Exists(xpathFromElement, 20000, "Check Object '{0}'", false);
}

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

Re: Tags, Web aplication and user code

Post by odklizec » Wed Apr 28, 2021 3:57 pm

Hi,

There are two things to try:
- Replace Path with AbsolutePath. Path returns path, relative to its parent. So if the element is buried in a nested structure of root folders, you may need to use AbsolutePath instead.
- Try to increase search timeout value.
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