I found a boilerplate on github and wanted to integrate a POM design to my BDD framework with Python-Behave and Selenium. My Python is not good, and i get this error: AttributeError: 'Context' object has no attribute 'get'
class Page(object):
def __init__(self, browser, base_url = 'https://someUrl.com'):
self.base_url = base_url
self.browser = browser
self.timeout = 30
def open(self,url):
self.browser.get(url)
class LoginPage(Page):
def visit_login_page(self, url):
self.open(url)
---
from pages import *
@when('a valid user clicking on the login button after typing in user name and password')
def step_impl(context):
page = LoginPage(context)
page.visit_login_page("https://someUrl.com")
#AttributeError: 'Context' object has no attribute 'get'
--
environment.py
from selenium import webdriver
def before_all (context):
#define a Chrome browser instance
context.browser = webdriver.Chrome()
context.browser.maximize_window()
context.browser.implicitly_wait(2)
def after_all(context):
context.browser.quit()
UPDATE
if i do:
page = LoginPage(context.browser)
it erros:
'LoginPage' object has no attribute 'visit_login_page'
Try this:
My base page (your page):
and one of my pages (login page):