Moving From QTP to Ranorex

Ranorex Studio, Spy, Recorder, and Driver.
Deepak_Singh
Posts: 76
Joined: Fri Mar 14, 2014 2:37 pm

Moving From QTP to Ranorex

Post by Deepak_Singh » Mon Mar 17, 2014 11:21 am

Hi, I will be moving from QTP to Ranorex tool because of project demand. Its a good tool for Record and Play back. But as far as scripting is concerned I am facing few problems. I am giving code's of opencart please help me with this via Ranorex coding(scripting).

1. Values from Excel
Dim objExcel,objWB,objSheet,strRegion

Set objExcel=CreateObject("Excel.Application")
Set objWB=objExcel.Workbooks.Open("D:\Deepak\Test Data\TC01TestData.xls")
Set objSheet=objWB.Worksheets("Sheet1")
strRegion=objSheet.Cells(2,"H")


2. Using Random Number
intRandom=RandomNumber(25,9999999)
Browser("Performance Store").Page("Register Account").WebEdit("email").Set "deepak"&intRandom&"@gmail.com"

3.Input Box for Captcha
strRunTimeText=InputBox("Please enter the given text.")
wait(2)
Browser("Performance Store").Page("Contact Us").WebEdit("captcha").Set strRunTimeText


4.Getting Price in dollars and Writing it in text file

Browser("Performance Store").Page("Wish List Link").WebElement("$").Click
wait(2)
strPriceInUS=Browser("Performance Store").Page("Wish List Link").WebElement("$199.99").GetROProperty("innertext")
MsgBox("Price in US Dollar is: "&strPriceInUS&" and is stored in D:\Deepak\Retrieved Data\PriceInUS.txt")

Set objFSO=createObject("Scripting.FileSystemObject")
Set objFile=objFSO.CreateTextFile("D:\Deepak\Retrieved Data\PriceInUS.txt")
objFile.WriteLine(strPriceInUS)
Set objFile=Nothing
Set objFSO=Nothing

5. Simple scripting to the following situation
Create a Login Function
Click on Login
Enter user Name
Enter Password
Click Login

Please help me for these codes with Scripting only.
Thanks In Advance.

Deepak_Singh
Posts: 76
Joined: Fri Mar 14, 2014 2:37 pm

Re: Moving From QTP to Ranorex

Post by Deepak_Singh » Wed Mar 19, 2014 5:53 am

Hello Support Team,
Please go through my post.
HELP Required. :?:
Hope to have a Reply Soon.

User avatar
Support Team
Site Admin
Site Admin
Posts: 12145
Joined: Fri Jul 07, 2006 4:30 pm
Location: Houston, Texas, USA
Contact:

Re: Moving From QTP to Ranorex

Post by Support Team » Wed Mar 19, 2014 3:47 pm

Deepak,

I would ask for your understanding that we cannot provide support on this.
This issue diverges too far from our supported field.
If you have Ranorex related questions we will be happy to help.

Regards,
Markus

Deepak_Singh
Posts: 76
Joined: Fri Mar 14, 2014 2:37 pm

Re: Moving From QTP to Ranorex

Post by Deepak_Singh » Thu Mar 20, 2014 1:07 pm

Support Team wrote:Deepak,

I would ask for your understanding that we cannot provide support on this.
This issue diverges too far from our supported field.
If you have Ranorex related questions we will be happy to help.

Regards,
Markus
Ok thanks, If you could help me in getting a property of an object like Innertext and save it to a excel or word file.
And one more doubt can we take User Input during run time Like we Have InputBox in VB scripting : I want tthat user should manualy enter his Username so how can i do that. please help.
Thanks in Advance.

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

Re: Moving From QTP to Ranorex

Post by odklizec » Fri Mar 21, 2014 8:24 am

Hi,

I'm afraid, there is no Input dialog in .NET definition, so you will either have to create your own dialog or use the one from Visual Basic (referencing VB library).

The easiest way is to use VB InputDialog. You can do it like this:

In Ranorex, go to menu Project >> Add Reference and in the appeared dialog (GAC tab) select "Microsoft.VisualBasic", then press [Select] and [OK].
VB_ref.png
VisualBasic reference should be added to the list of references...
VB_ref_2.png
Now go to Program.cs and here add below line for example at the end of existing "using" directives

Code: Select all

using Microsoft.VisualBasic;
Then still in Program.cs, add below line at the beginning of the Main method (like this):
public static int Main(string[] args)
        {
			// Test of VB input box
			string retName = Interaction.InputBox("Name Please", "Name", "enter your name");
Now if you compile and run your project, there should be issued a simple Input box, where you can enter your name. The test will continue to run only after closing this dialog. The question is, how do you you want to use the variable containing the name from Input box?

The more complicated way would be to create your own Input dialog using C#/VB.NET code. This would give you more flexibility (like multiple input fields in the same dialog), but this may not be as easy to implement as the above solution. Check for example this custom InputBox sample: http://www.csharp-examples.net/inputbox/
You do not have the required permissions to view the files attached to this post.
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