Use system information in control paths : Object Identification and Technologies

Use system information in control paths

Technology specific object identification, supported applications, web technologies, and 3rd party controls.

Use system information in control paths

Postby AntiDot » Mon Jul 11, 2011 4:25 pm

Hi guys,
I'm creating a script on creating and validating virtual directories in IIS.

In an attempt to keep the script generic so it can be run on different computers and scenarios, I've hit a wall: I cannot find the "LOCAL COMPUTER" node in IIS without hardcoding the computer name, which will be problematic on other computers.
Have considered using key sequences, but unfortunately the node is not always in the same position. :(

Could get it working briefly by modifying the control path's line in the Repository.cs file as follows (C#):
Code: Select all
[language=csharp]
_treeitemComputerName = new RepoItemInfo(this, "treeItemComputerName", "container/form/element/tree/treeitem/treeitem[@text>'" + System.Environment.MachineName + "']", 30000, null, "0f696513-a295-414b-b381-0592758cb3ca");
[/language]


However, this change is overwritten every time the code generation kicks in.

Snapshot of the control and other information for what it's worth:
- OS: Win7 / SP1 / Server 2008
- IIS: IIS 7.5 / IIS 7 / IIS 6.0
- RANOREX: 3.0.2.12718

:?: What I need is a way to pull system information, such as the computer name, directly into my control path.
Any help would be appreciated.

Thanks!
Attachments
IIS_Issue.rxsnp
(152.88 KiB) Downloaded 10 times
AntiDot
 
Posts: 3
Joined: Mon Jul 11, 2011 3:20 pm

Re: Use system information in control paths

Postby Support Team » Mon Jul 11, 2011 8:59 pm

Is the local computer node always the first child of the "Internet Information Services" node? If so, the easiest way is to use a path like the following:
Code: Select all
container/form/element/tree/treeitem[@text='Internet Information Services']/treeitem


AntiDot wrote:However, this change is overwritten every time the code generation kicks in.

If the above alternative does not work, the easiest way is to create a variable for the text of that tree item with the local computer name and a global parameter that is bound to that variable. Then add a user code module to your test suite, mark it as "Setup", and in the user code set the global parameter. See following section in the Ranorex User Guide for more info on achieving the individual steps:
http://www.ranorex.com/support/user-gui ... html#c3003]
http://www.ranorex.com/support/user-gui ... html#c2985
http://www.ranorex.com/support/user-gui ... html#c3201

Regards,
Alex
Ranorex Team
User avatar
Support Team
Site Admin
 
Posts: 4845
Joined: Fri Jul 07, 2006 5:30 pm
Location: Graz, Austria

Re: Use system information in control paths

Postby AntiDot » Tue Jul 12, 2011 8:25 am

Thanks for your reply, Alex.
Unfortunately that node is not always first in the tree. And when it's not, the first node's name is also different in the various environments: sometimes it is "Start Page" and other times "Internet Information Services".

But I'll give your other suggestion a shot.
Thanks again!
AntiDot
 
Posts: 3
Joined: Mon Jul 11, 2011 3:20 pm

Re: Use system information in control paths

Postby sdaly » Tue Jul 12, 2011 9:27 am

AntiDot wrote: sometimes it is "Start Page" and other times "Internet Information Services".


To overcome this you could just put an OR in your Rxpath I think...
@text='Internet Information Services' or @text='Start Page'
User avatar
sdaly
 
Posts: 213
Joined: Mon May 10, 2010 12:04 pm
Location: Dundee, Scotland

Re: Use system information in control paths

Postby AntiDot » Tue Jul 12, 2011 12:56 pm

Thanks, Scott!
Used "AND" to eliminate possible ambiguity and now it works like a charm! {{VICTORY DANCE}}

I'm sure there is a much better way to get and feed the exact information, but my C# skills are still too green. But I think a simple way to pull system information into control paths would be a nice feature for Ranorex.

Thank you for everybody's help! :D
AntiDot
 
Posts: 3
Joined: Mon Jul 11, 2011 3:20 pm


Return to Object Identification and Technologies

Who is online

Users browsing this forum: No registered users and 0 guests

cron