Page 1 of 1

IronPython code example

Posted: Fri Mar 25, 2011 3:39 pm
by piotrn
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()
------------------------------------------------------------------

Re: IronPython code example

Posted: Fri Mar 25, 2011 7:05 pm
by Support Team
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