Skip to content
This repository has been archived by the owner on Sep 16, 2021. It is now read-only.

NameError: name 'Newsletter' is not defined #147

Open
anilreddy opened this issue Oct 3, 2019 · 1 comment
Open

NameError: name 'Newsletter' is not defined #147

anilreddy opened this issue Oct 3, 2019 · 1 comment

Comments

@anilreddy
Copy link

Hi,

Am using the below code provided in the documentation am getting the following error when I ran it. How to resolve this issue.

Code:

# mozilla.py
from pypom import Page, Region
from splinter import Browser

executable_path = {'executable_path':'C:/Users/tester/.webdrivers/chromedriver.exe'}

class Mozilla(Page):
    URL_TEMPLATE = 'https://www.mozilla.org/'

    @property
    def newsletter(self):
        return Newsletter(self)

    class Newsletter(Region):
        _root_locator = ('id', 'newsletter-form')
        _submit_locator = ('id', 'footer_email_submit')

        def sign_up(self):
            self.find_element(*self._submit_locator).click()

driver = Browser('chrome', **executable_path)
page = Mozilla(driver).open()
page.newsletter.sign_up()

Error:

Traceback (most recent call last):
  File "mozilla.py", line 22, in <module>
    page.newsletter.sign_up()
  File "mozilla.py", line 11, in newsletter
    return Newsletter(self)
NameError: name 'Newsletter' is not defined
@symonk
Copy link

symonk commented Jan 9, 2021

@anilreddy you have not imported the Newsletter class in your module; whatever that type may be

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants