I`m writing simple scripts for test automation using Selenium WebDriver in Python, but the issue relates to Python, not to Selenium. There two classes FindByXPATH_1(base) & FindByXPATH_2(derived). I want to call an attribute "driver" from the base class in a method of FindByXPATH_2, but when I ran the code the AttributeError shows up: "type object 'FindByXPATH_1' has no attribute 'driver'"
Here is the code:
class FindByXPATH_1():
def __init__(self):
self.driver_location = '/usr/local/bin/chromedriver'
self.driver = webdriver.Chrome(self.driver_location)
self.driver.get('https://letskodeit.teachable.com/p/practice')
from basics.xpath_1 import FindByXPATH_1
import basics #the classes are in two different python files
class FindByXpath_2(FindByXPATH_1):
def __init__(self):
FindByXPATH_1.__init__(self)
def find_by_starts_with(self):
starting_with = FindByXPATH_1.driver.find_elements(By. XPATH,
'//div[@class="view-school"]//h3[starts-with(@)class, "subtitle"]')
print(len(starting_with))
test = FindByXPATH_2()
test.find_by_starts_with()
After running the code I get a message "AttributeError: type object 'FindByXPATH_1' has no attribute 'driver'" How can I call that attribute?