Workaround for having an adapter as a variable

Technology specific object identification, supported applications, web technologies, and 3rd party controls.
andy.simpson
Posts: 32
Joined: Fri Jun 22, 2018 8:59 am

Workaround for having an adapter as a variable

Post by andy.simpson » Mon Apr 08, 2019 10:21 am

Hi, me again ;)

I have a scenario where we have a standard indexing screen where fields are enabled/disabled for each customer as they require them. Ideally I want to have a code module which can dynamically index the boxes based on whether they are enabled/disabled by using a data driven excel spreadsheet with the repo elements being passed in as variables. This seems to work apart from the fact that adapters cannot be variables as shown here

how-to-force-ranorex-adapter-to-be-used ... 11876.html

Its notes here that using a * as an adapter rather than passing the adapter in but I'm unclear as to how this actually works.

On a broader note is this a good solution or is there better way of going about it? really want the repo items to be data driven to save having multiple recording modules for the different configurations of index screen

I've attached a snapshot, & screenshots of my code module an data driven info

again any advice would be appreciated
Attachments
disabled snapshot.rxsnp
(149.16 KiB) Downloaded 10 times
DataDrivenExcel.PNG
DataDrivenExcel.PNG (52.49 KiB) Viewed 323 times
Code for a data driven repo elements.PNG
Code for a data driven repo elements.PNG (23.08 KiB) Viewed 324 times

manish
Posts: 46
Joined: Fri Aug 10, 2018 12:46 pm

Re: Workaround for having an adapter as a variable

Post by manish » Mon Apr 08, 2019 3:11 pm

Hi,

Instead of Adapter as the Type, you could try to use Ranorex.ElementType if you alread know the Type of FieldToBeValidated.
Untitled.png
Untitled.png (16.73 KiB) Viewed 306 times
Also, if this does not work or if you do not know the type of elemnt beforehand, you could use
Unbenannt1.png
Unbenannt1.png (5.11 KiB) Viewed 306 times
Hope it solves the issue

Thanks
Manish

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

Re: Workaround for having an adapter as a variable

Post by andy.simpson » Fri Apr 12, 2019 8:45 am

Sorry I'm not sure I quite understand your explanation

User avatar
Support Team
Site Admin
Site Admin
Posts: 11986
Joined: Fri Jul 07, 2006 4:30 pm
Location: Graz, Austria

Re: Workaround for having an adapter as a variable

Post by Support Team » Tue Apr 16, 2019 12:26 pm

Hello Andy,

The column "Repository RxPath" in your screenshot doesn't contain a RxPath, it contains the classpath to the object represented as a string. Your method expects an Adapter object.
I would recommend using the RanoreXPath instead, then you can use Unknown instead of the adapter.
public void ClickMyElement(string MyRxPath)
{
   Ranorex.Unknown myElement =  MyRxPath;
   myElement.Click();
}
I hope this helps.

Regards,
Bernhard
.
Image

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

Re: Workaround for having an adapter as a variable

Post by andy.simpson » Thu Apr 18, 2019 1:41 pm

That works thanks :) Am I right in thinking that if I want to validate an adapter attribute (like its class) against a data driven spreadsheet then there is no way of achieving this other than to have a separate adapter for each validation?

User avatar
Support Team
Site Admin
Site Admin
Posts: 11986
Joined: Fri Jul 07, 2006 4:30 pm
Location: Graz, Austria

Re: Workaround for having an adapter as a variable

Post by Support Team » Tue Apr 23, 2019 12:04 pm

Hi andy,

You can use the following code to get the value of the class property, but be careful, not every element has a class property.
myElement.Element.GetAttributeValue("Class");
Regards,
Bernhard
.
Image

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

Re: Workaround for having an adapter as a variable

Post by andy.simpson » Wed Apr 24, 2019 11:42 am

Great thanks :)