IronPython code example

Class library usage, coding and language questions.
piotrn
Posts: 16
Joined: Fri Mar 25, 2011 3:04 pm

IronPython code example

Post by piotrn » Fri Mar 25, 2011 3:39 pm

Hi
Is it possible to get a valid IronPython (IronPython 2.7 (2.7.0.40) on .NET 4.0.30319.1)
code example? The example provided in the Ranorex User Guide: Visual Studio Integration does not really work.

I've tried with the following modified version but still 'Form' (and other Ranorex classes) cannot be found....
------------------------------
import clr
clr.AddReferenceByPartialName("System.Drawing")
clr.AddReferenceByPartialName("IronPython")
clr.AddReferenceByPartialName("Ranorex.Core")
clr.AddReferenceByPartialName("Ranorex.Controls")

from System.Drawing import *
from Ranorex.Core import *
from Ranorex.Controls import *

import System
import IronPython

def Main():
error = 0
try:
System.Diagnostics.Process.Start("calc.exe")
form = Form(Host.Local.FindChild("Calculator"))
form.Activate()
button = Button(form.FindChild("2"))
button.Click()
button = Button(form.FindChild("*"))
button.Click()
button = Button(form.FindChild("3"))
button.Click()
button = Button(form.FindChild("="))
button.Click()

except Exception, e:
print(e.ToString())
error = -1

return error

Main()
------------------------------------------------------------------

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

Re: IronPython code example

Post by Support Team » Fri Mar 25, 2011 7:05 pm

Hi,

Here is a little example:

Code: Select all

import clr
clr.AddReference('Ranorex.Core')
import Ranorex;
bt = Ranorex.Button("/form[@controlname='formVipApplication']/button[@controlname='btAdd']")
bt.Click()
 
Regards,
Roland
Ranorex Support Team