How to integrate my own DataConnector in Ranorex Studio?

Class library usage, coding and language questions.
wf1
Posts: 7
Joined: Thu Jun 21, 2012 10:03 am

How to integrate my own DataConnector in Ranorex Studio?

Post by wf1 » Thu Jun 21, 2012 11:48 am

As the built in Ranorex DataConnectors do not really fulfill all my needs, I have implemented my own DataConnector class derived from the Ranorex.Core.Data.DataConnector class.
Then I added the line

Code: Select all

DataConnectorFactory.RegisterDataConnectorType(typeof(myConnector));

at the begin of the main() method and manually edited the xml file myTestSuite.rxtst in such a way that I added a section for my own DataConnector and replaced the reference to the DataConnector within the test cases by a reference to my own DataConnector.
So far so good. I am able now to execute my test suite with my own DataConnector just like with a built in DataConnector.
The only problem is that I cannot view my test suite any longer in the Ranorex Studio. When I click on the button "View Test Suite" an error pops up saying that the Test Suite cannot be loaded and that the TestSuite XML format is invalid. The exception text is "Failed to construct data connector for unknown type 'myConnector'.

Therefore my question is: Is it possible to integrate / register my own DataConnector in some way within the Ranorex Studio so that I can use it there just like any built in DataConnector without getting the error mentioned above?

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

Re: How to integrate my own DataConnector in Ranorex Studio?

Post by Support Team » Fri Jun 22, 2012 1:34 pm

Hi,

we will have a look at this issue and inform you about our progress.


Regards,
Tobias
Ranorex Team
.
Image

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

Re: How to integrate my own DataConnector in Ranorex Studio?

Post by Support Team » Mon Jun 25, 2012 8:50 am

Hi,

please have a look at the attached ZIP file, which holds a custom connector sample.
To make it work, place the custom connector assembly in the Ranorex plug-in folder (e.g. for Ranorex 3.*: C:\ProgramData\Ranorex3\Plugins).
Please have a look at this solution and see how to integrate.

Note: You can extend the configuration of your custom connector with a GUI within CustomConnectorConfig.cs.

Regards,
Tobias
Ranorex Team
Attachments
CustomConnector.zip
(5.62 KiB) Downloaded 366 times
.
Image

wf1
Posts: 7
Joined: Thu Jun 21, 2012 10:03 am

Re: How to integrate my own DataConnector in Ranorex Studio?

Post by wf1 » Mon Jun 25, 2012 1:54 pm

Thanks Tobias, that's exactly what I was looking for. It is working fine.

Regards,
wf1

wf1
Posts: 7
Joined: Thu Jun 21, 2012 10:03 am

Re: How to integrate my own DataConnector in Ranorex Studio?

Post by wf1 » Tue Jun 26, 2012 1:40 pm

Hi Tobias,

I have one more question: Which method do I have to override to get the extended connector config GUI filled with the data from the corresponding section within the TestSuite.rxtst file? I didn't find the method which has access to the xml node containing those data.

Regards,
wf1

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

Re: How to integrate my own DataConnector in Ranorex Studio?

Post by Support Team » Tue Jun 26, 2012 2:25 pm

Hi,

plase have a look in the attached solution.
Here you will recognize the implementation of SetConfigData and SaveConfigData in CustomConnectorConfig.cs as well as the changes in GetXMLNode and the constructors in CustomConnector.cs.

Regards,
Tobias
Ranorex Team
Attachments
CustomConnector.zip
(8.07 KiB) Downloaded 285 times
.
Image

wf1
Posts: 7
Joined: Thu Jun 21, 2012 10:03 am

Re: How to integrate my own DataConnector in Ranorex Studio?

Post by wf1 » Wed Jun 27, 2012 9:31 am

Hi Tobias,

thanks, SetConfigData() was the method I was looking for.
But now I have the next question:
When I have created an instance of my custom connector in the dialog "Manage Data Sources" and then click on "OK" then the data of my custom connector are added to the TestSuite.rxtst file as expected. But when I afterwards change any values of this instance in the my custom extended connector config GUI then the "Apply" button does not become enabled and when I click on "OK" then the TestSuite.rxtst file will not be updated with the changed values. I tried to set the property DataConnectorConfig.IsConfigDirty to true and I also tried to call the DataConnectorConfig.OnDataConnectorConfigChanged() method but that does not help. How can I inform the base DataConnectorConfig class that there are changes in my extended UI elements so that the Apply button becomes enabled and the SaveConfigData() method will be called again when I click on "OK"?

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

Re: How to integrate my own DataConnector in Ranorex Studio?

Post by Support Team » Wed Jun 27, 2012 10:31 am

Hi,

you have to add onChange event for the text box which calls OnDataConnectorConfigchanged.
Additionally you have to apply the text from the text box to your connector in SaveConfigData as you can see in attached solution.

Regards,
Tobias
Ranorex Team
Attachments
CustomConnector.zip
(11.97 KiB) Downloaded 326 times
.
Image

wangxu
Posts: 1
Joined: Fri Nov 23, 2012 6:26 am

Re: How to integrate my own DataConnector in Ranorex Studio?

Post by wangxu » Fri Nov 23, 2012 6:36 am

Hi,

I am new here, and I want to learn from the CustomConnector example, but on my machine I got error
"The type or namespacename 'DataConnectorConfig' could not be found(are you missing...)" while building the project, what can I do next? :?
I have just installed the Ranorex studio tiral version 3.3.4, please help.
Thanks.

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

Re: How to integrate my own DataConnector in Ranorex Studio?

Post by Support Team » Fri Nov 23, 2012 11:36 am

Hi,

Could it be that you wanted to use the "CustomConnectorConfig" file?
Could it be that you forgot to reference the specific assembly?
Can you explain the steps you have performed before you got this message?

Regards,
Markus
.
Image