mardi 2 mars 2021

Getting the error in python selenium testing for login and logout functionality

I am getting the error as...

AttributeError: 'LoginTestCase' object has no attribute 'driver'

And the code is

from selenium import webdriver;
from selenium.webdriver.common.keys import Keys
import time
import unittest

class LoginTest(unittest.TestCase):
    
    @classmethod
    def setUpclass(cls):
        cls.driver = webdriver.Firefox("D:/Frontend/18-01-2021/selenium-testing")
        cls.driver.implicitly_wait(10)
        cls.driver.maximize_window()

    
     def test_login_valid(self):
        self.driver.get("http://localhost:4200")
        self.driver.find_element_by_name("username").send_keys("admin")
        self.driver.find_element_by_name("password").send_keys("admin@123")
        self.driver.find_element_by_id('log').click()
        self.driver.find_element_by_id('ab').click()
        self.driver.find_element_by_id('usersinfo').click()
        self.driver.find_element_by_id('log_out').click()
        time.sleep(8)

    @classmethod
    def tearDownClass(cls):
        cls.driver.close()
        cls.driver.quit()
        print("Test Completed")

I have built the above code for testing login to functionality using selenium with python unit testing . But while executing the python code showing some errors as

AttributeError: 'LoginTestCase' object has no attribute 'driver'

Can anyone help me regarding this

Aucun commentaire:

Enregistrer un commentaire