Hello,
In Ranorex Studio 3.0 to make a DLL starting from an existing solution, right-click on the solution choose Add, then New Project, then choose Advanced, then Ranorex Class Library. You could also choose Module, then Ranorex Test Suite Module Library. A module in Ranorex is something you can drag into the test suite. By doing so the DLL would be automatically added to the list of references of your main test suite executable. Else you need to add the DLL using "Add Reference" in the context menu of the reference list of your (test suite) executable.
In your case a similar functional block of controls is spread over more applications. You could use RanoreXPaths like
- Code: Select all
/.//text[@accessiblename="nameyouprovideCouldbeOtherAttributeToo"]
But then the whole desktop is searched which makes is slow.
You should therefore provide a root path to the function in the DLL, too, in order to make it faster. The root path is part of the repository entry. You could access it using the
FolderClass.AbsoluteBasePath for folder entries or
EntryNameInfo.AbsolutePath for repository entry
EntryName.
Another way would be to provide the adapter instance for the container in the argument list of your function. In the function you use
FindSingle of the adapter instance.
If you compile your DLL with .NET 3.5, then this could also be done using extension classes, in which you mark the first argument of your static function of a static class with
this.
public static class BlockOne
{
public static void FillWithData(this Ranorex.Adapter parent, string firstnamecontrol, string firstname, string lastnamecontrol, string lastname)
{
Ranorex.Text firstname_adapter = parent.FindSingle(".//text[@accessiblename='"+firstnamecontrol+"']");
firstname_adapter.TextValue = firstname;
Ranorex.Text lastname_adapter = parent.FindSingle(".//text[@accessiblename='"+lastnamecontrol+"']");
lastname_adapter.TextValue = lastname;
Ranorex.Button addbutton = parent.FindSingle(".//button[@controlname='btAdd']");
addbutton.Click();
}
}Then you can use your function from the DLL as though it was a function of the container's adapter.
repo.FormVIP_Database.Self.FillWithData("First Name:", "John", "Last Name:", "Travolta");Note: Repository folder entries are not adapter classes. For them the Self member must be used.
Regards,
Roland
Ranorex Support Team