I want to get the variable browser
from self.login()
function and use it in the test_pages
function. browser=?
is where I want to use the variable.
How do I do that?
def test_pages(self, browser=?):
self.login()
pages = ["page1", "page2", "page3"]
for page in pages:
browser.visit(f"{self.base_url}/test/{page}")
if browser.is_text_present('Log Out'):
print("navigate_" + page + " Pass")
else:
print("navigate_" + page + " Fail")
def login(self):
browser = Browser('chrome')
browser.visit(f"{self.base_url}/login")
browser.fill('email', self.get_user_email())
browser.fill('password', self.get_user_password())
# Find and click the 'search' button
button = browser.find_by_value("Sign In")
# Interact with elements
button.click()
return browser
Just use the value returned by self.login()
in test_pages()
as follows:
browser = self.login()