Причина, по которой вы получаете эту ошибку, заключается в том, что вы обращаетесь к атрибуту driver
self
при вызове метода wait_for_page_to_load(self)
.То есть, когда вы передаете в веб-драйв Firefox методу, self
ссылается на веб-драйвер Firefox, поэтому он пытается получить доступ к атрибуту driver
веб-драйвера Firefox, что неверно.
Чтовам нужно создать экземпляр объекта Navigation
, чтобы self
ссылался на указанный объект, а self.driver
ссылался на драйвер Firefox, который вы передаете. Из вашего кода я ожидал что-то вроде этого:
def before_all(context):
# These 4 lines are independent of the Navigation class
driver = DriverSetup.get_driver()
context.actionwords = Actionwords()
base_url = ''
driver.get(base_url)
# These 2 lines are dependent on the Navigation class
# On the right, the Navigation object is instantiated
# On the left, the object is initialized to the navigation_driver variable
navigation_driver = AutoTools.Navigation(driver)
# After, you can call your method since the object's self.driver
# was instantiated in the previous line and properly refers to the Firefox webdriver
navigation_driver.wait_for_page_to_load()