I am running some unittests with Selenium Webdriver that tests a couple websites.
I am basically trying to submit an order through a store, take the order number, and search for that order number on a different website.
I need these to be two separate tests.
I do not want to include the 'search for order number' within the first test, because 1. The 'submit an order' test is already 100+ lines, and 2. There needs to be a clear division between submitting an order pass/fails, and the order is then in the database pass/fail (if that makes sense).
Please see a snippet of my tests below.
class SmokeTest(unittest.TestCase):
def setUp(self):
self.driver = webdriver.Firefox()
self.driver.implicitly_wait(30)
self.base_url = "http://test.com"
self.verificationErrors = []
self.accept_next_alert = True
def test_complete_an_order(self):
'''complete an order'''
return ordernumber
def check_ordernum_exists(self):
driver = self.driver
driver.get("https://testdb.com")
csp_user = driver.find_element_by_id("j_username")
csp_user.send_keys("test")
csp_pass = driver.find_element_by_id("j_password")
csp_pass.send_keys("test")
ordernum = driver.find_element_by_id('tb_order_number')
ordernum.send_keys(ordernumber)
As you can see, I'm trying to return "ordernumber" from the first test, and fill out a field in the next test using this ordernumber?
My question is, is this even possible within the unittest framework and how can I accomplish this?