Module 23:Framework issue | Selenium Python Forum
M
M Prabhaharan Posted on 13/06/2020

Basetest.py code

'''
Created on Jun 6, 2020

@author: prabha
'''
from selenium import webdriver
class abc():

def OpenBrowser(self,browserName):
if(browserName == "chrome"):
self.driver=webdriver.Chrome()
self.driver.implicitly_wait(5)
elif(browserName == "mozilla"):
self.driver=webdriver.Firefox()
self.driver.implicitly_wait(5)
self.driver.maximize_window()


def Navigate(self,stringURL):
self.driver.get(stringURL)


def click(self):
pass

def type(self):
pass

def verifyTitle(self):
pass

def verifyText(self):
pass

def ReportPass(self,stringMsg):
pass

def ReportFail(self,stringmsg):
pass

def takeScreenshot(self):
pass

--------------------------------------------------------

testdummyB code

'''
Created on Jun 6, 2020

@author: prabha
'''
from DataDrivenFramework.BaseTest import abc

def test_B1():
base=abc()
base.OpenBrowser("Chrome")
base.Navigate("https://mail.google.com")

-------------------------------

while executing above code below errors are coming

============================= test session starts =============================
platform win32 -- Python 3.7.6, pytest-5.3.5, py-1.8.1, pluggy-0.13.1
rootdir: C:\Users\prabha\eclipse-workspace\SeleniumWithPython
plugins: allure-pytest-2.8.13
collected 1 item

DataDrivenFramework\testdummyB.py F [100%]

================================== FAILURES ===================================
___________________________________ test_B1 ___________________________________

def test_B1():
base=abc()
base.OpenBrowser("Chrome")
> base.Navigate("https://mail.google.com")

DataDrivenFramework\testdummyB.py:11:
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _

self = <DataDrivenFramework.BaseTest.abc object at 0x000000000416AB48>
stringURL = 'https://mail.google.com'

def Navigate(self,stringURL):
> self.driver.get(stringURL)
E AttributeError: 'abc' object has no attribute 'driver'

DataDrivenFramework\BaseTest.py:20: AttributeError
============================== 1 failed in 0.34s ==============================

 


0
09914040666 Replied on 17/06/2020

 

Hey, 

Please use this code in the basetest:

from selenium import webdriver
class abc():
    def OpenBrowser(self, browsername):
        if(browsername=='Chrome'):
            self.driver = webdriver.Chrome()
            self.driver.implicitly_wait(5)
            self.driver.maximize_window()
        elif(browsername=='Firefox'):
            self.driver = webdriver.Firefox()
            self.driver.implicitly_wait(5)
            self.driver.maximize_window()
      
    def Navigate(self, stringURL):
        self.driver.get(stringURL)


M
M Prabhaharan Replied on 17/06/2020

Still same issue exist i copied your code 

please find screen shot attached


0
09914040666 Replied on 18/06/2020

Hey, Kindly please share your project so that the issue could be checked.


M
M Prabhaharan Replied on 19/06/2020

Hey file attached for your reference


0
09914040666 Replied on 22/06/2020

Hey, 

Python is case sensitive and in the BaseTest you are checking if browsername = 'chrome' and in the testdummyB module you are passing argument as 'Chrome' because of which this error is coming. 

Kindly please give the same arguments as per your condition given and try to correct it in either the BaseTest from 'chrome' to 'Chrome' and your code will run fine.


Related Posts