TestComplete Python Scripting
Hello Everyone,
I came from the world of C# and Selenium automated testing and I'm trying to find my ground with scripting in TestComplete.
In C#, I can create extension methods to shorten code and make things much more readable and I'm trying to translate that into python scripts for TestComplete. Here is my example:
Method : ClickOn
browser = Sys.Browser()
page = browser.Page()
def ClickOn(button): obj = page.FindChildByXpath(button, True) if (GetVarType(obj) != varNull): obj.Click() else: Log.Message('Unable to locate button') return button
LookForObject Method:
def LookForObject(object): obj = page.FindChildByXpath(object) if (GetVarType(obj)) != varNull: Log.Message("Verified Object Exists") else: Log.Message("Object is not present on page") return object
NameMapping file:
SignInPage_SignInButton = "//[@TesterXPath]";
Actual Script:
import Actions import SiteCore_NameMapping def U010_Navigate_to_SiteCore_Login_Page(): #Clicks on the the Sign In button in the Navigation Bar Actions.ClickOn(NavigationBar_SignInButton) #Validates navigation was successful by verifying fields and buttons exist Actions.LookForObject(SignInPage_SignInButton) Actions.LookForObject(SignInPage_SignInEmailField) Actions.LookForObject(SignInPage_SignInPasswordField)
My problem may be two-fold; I'm still getting familiar with Python syntax, and I'm still learning how TestComplete will be able to interpret my scripting (Maybe threefold, I'm very stuck in my ways with how simple scripts can look with C# :smileyhappy: )
Anyway, I'm receiving a runtime error: Python runtime error:
NameError: name 'NavigationBar_SignInButton' is not defined
Can someone please shed some light as to why I'm receiving this error? As you can see I did define the variable but maybe not in the correct/needed format?