0

I'm new in Selenium automation with Python. I was designing this hybrid framework for login. I get this error and don't know what the problem is.

def test_login(self):
        self.driver=webdriver.Chrome("C:\\Users\\91808\\Documents\\Chrome selenium package\\chromedriver.exe")
        self.driver.get(self.baseurl)
        #import login action methods from page object file
        self.Lp=Logintest(self.driver)
        self.Lp.setUserName(self.username)

Error

AttributeError: 'Logintest' object has no attribute 'setUserName'**

Code :

enter image description here

1

1 Answer 1

3

You have the functions inside the init constructor like this:

class test:
    def __init__(self):
        self.msg = "Hello World"
        
        def hello(self):
            print(self.msg)

Instead, declare your functions outside the init method like this:

class test:
    def __init__(self):
        self.msg = "Hello World"
        
    def hello(self):
        print(self.msg)
Sign up to request clarification or add additional context in comments.

Comments

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.