1

Learning Selenium driven by Python and in my practice I keep getting the following error. I am stuck and could use some guidance

Traceback (most recent call last): File "test_login.py", line 14, in test_Login loginpage = homePage(self.driver) TypeError: 'module' object is not callable

Here is my code

test_login.py

import unittest
import homePage
from selenium import webdriver

class Login(unittest.TestCase):

  def setUp(self):
     self.driver = webdriver.Firefox()
     self.driver.get("https://hub.docker.com/login/")

  def test_Login(self):
      loginpage = homePage(self.driver)
      loginpage.login(email,password)

  def tearDown(self):
      self.driver.close()

if __name__ == '__main__': unittest.main()

homePage.py

from selenium.webdriver.common.by import By

class BasePage(object):

    def __init__(self, driver):
        self.driver = drive


class LoginPage(BasePage):
    locator_dictionary = {
        "userID": (By.XPATH, '//input[@placeholder="Username"]'),
        "passWord": (By.XPATH, '//input[@placeholder="Password"]'),
        "submittButton": (By.XPATH, '//button[text()="Log In"]'),
    }



    def set_userID(self, id):
        userIdElement = self.driver.find_element(*LoginPage.userID)
        userIdElement.send_keys(id)

    def login_error_displayed(self):
        notifcationElement = self.driver.find_element(*LoginPage.loginError)
        return notifcationElement.is_displayed()

    def set_password(self, password):
        pwordElement = self.driver.find_element(*LoginPage.passWord)
        pwordElement.send_keys(password)        

    def click_submit(self):
        submitBttn = self.driver.find_element(*LoginPage.submitButton)
        submitBttn.click()

    def login(self, id, password):
        self.set_password(password)
        self.set_email(id)
        self.click_submit()

Any help is appreciated

1 Answer 1

1

I think here:

loginpage = homePage(self.driver)

you meant to instantiate the LoginPage class:

loginpage = homePage.LoginPage(self.driver)
Sign up to request clarification or add additional context in comments.

4 Comments

Thank you for your fast respose.
Now I am getting: Traceback (most recent call last): File "test_login.py", line 16, in test_Login loginpage.login('ID','PW') File "homePage.py", line 31, in login self.set_userID(id) File "/homePage.py", line 18, in set_userID userIdElement = self.driver.find_element(*LoginPage.userID) AttributeError: type object 'LoginPage' has no attribute 'userID' Where should I focus or look for this error's cause? Thanks
@user1279586 you have a typo - see drive vs driver.
Not seeing it. again, still learning, do can you point me to the line for referncing and research?

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.