Forum Discussion

testfeast's avatar
Occasional Contributor
9 months ago

Using Page Object as return type

Trying to write a function like:

def foo() -> Page:
 #does something
 return page

It returns a variable of type Page in TestComplete.


However, it gives me a runtime error: NameError: name 'Page' is not defined.

How should I change my code?

1 Reply

  • rraghvani's avatar
    Champion Level 3

    You need to define a Type Alias first, e.g.

    Page = Sys.Browser().Page("") # Type Alias
    def MyPage() -> Page:
        return Page
    def main():