So I'm trying to get started writing automated testing using the Splinter framework. When I run the first method the browser just closes. What I need is to keep the same browser open and allow me to call another method that will act on that browser as well. I'm confused as to why it's closing because splinter has a browser.quit()
which I would think I would have to call to quit but as seen below I'm not calling anything like that.
from splinter import Browser
def testLogin(ipaddress, username):
global browser
with Browser('chrome') as browser:
url = "http://%s" % ipaddress
browser.visit(url)
browser.fill('EmailAddress', username)
browser.fill('Password','123456789')
button = browser.find_by_id('login')
button.first.click()
if browser.is_text_present('Summary of Orders'):
print("Pass: Login was succesful")
elif browser.is_text_present('There are currently no orders that are available for you to browse.'):
print("Pass: Login was succesful")
else:
print("Fail: Login was not succesful")
return
def createOrder():
browser.find_by_id('nav-OrderModule-Create').first.click()
browser.fill('nameBox','test')
testLogin("ipaddress","my@email")
createOrder()