I am trying to automate an ecom website. I need to run DB query after placing 
each order.  I don't know how to run different queries after each order.  Can 
someone help me out with having queries after each order submission or test?  
If you notice, I'm calling self.database_verification() after test 1.  So for 
the second test the query would be different, something like, Select * from 
PORTFOLIO_ORDER where MEMBER = 'USA' AND SYMBOL = 'TOP' OR SYMBOL = 'Sweater.  
Basically for the sequence of orders, i would have different queries.  So what 
is the best way to write the code?


class OrderInputScreen(unittest.TestCase):
    def setUp(self):        self.driver = webdriver.Firefox()        driver = 
self.driver        
driver.get("http://testserver:8080/OrderInputScreen/login#/";)        
driver.maximize_window()
    def database_verification(self):    con = 
cx_Oracle.connect('user/user@testDB123')  cur = con.cursor()      
cur.execute("Select * from US_ORDER where SYMBOL = 'TOP' and SIZE = 'M'")       
for result in cur:          print result[2:8]   cur.close()                 
#USA single Order and verification
    def __test_single_order(self):        driver = self.driver        elem = 
driver.find_element_by_name("username")    elem.send_keys("TEST")  elemPassword 
= driver.find_element_by_name("password")  elemPassword.send_keys("TEST")  
elem.submit()        member = 
driver.find_element_by_xpath("//form/div/dl/dd[1]/input")        member.click() 
       member.send_keys("USA")        PayType = driver.find_element_by_xpath 
("//form/div/dl/dd[2]/input")        PayType.click()        
PayType.send_keys("USD")        clickPayType = driver.find_element_by_xpath 
("//form/div/dl/dd/ul/li/a")        clickPayType.click()        Symbol =  
driver.find_element_by_xpath ("//form/div/dl/dd[3]/input")        
Symbol.click()        Symbol.send_keys("TOP")        Quantity = 
driver.find_element_by_name ("quantity")        Quantity.click()        
Quantity.send_keys("10")        Price = driver.find_element_by_name ("price")   
     Price.click()        Price.send_keys("56.99")        Size = 
driver.find_element_by_xpath ("//form/div/dl/dd[6]/select/option[text()='M']")  
      Size.click()        SubmitButton = driver.find_element_by_xpath 
("//form/div/dl/dd[11]/div[2]")        SubmitButton.click()       
ActualOrderMsg = driver.find_element_by_xpath ("//span/p").text         print 
ActualOrderMsg    textPresent = driver.find_element_by_xpath 
("//span/p[contains(text(), 'Successfuly added to processing!')]")        
self.database_verification()       
            #USA -multiple orders and verification
    def test_Multiple_order(self):      #Order0
        driver = self.driver        elem = 
driver.find_element_by_name("username")      elem.send_keys("TEST")  
elemPassword = driver.find_element_by_name("password")  
elemPassword.send_keys("TEST")  elem.submit()        member = 
driver.find_element_by_xpath("//form/div/dl/dd[1]/input")        member.click() 
       member.send_keys("USA")        PayType = driver.find_element_by_xpath 
("//form/div/dl/dd[2]/input")        PayType.click()        
PayType.send_keys("USD")        clickPayType = driver.find_element_by_xpath 
("//form/div/dl/dd/ul/li/a")        clickPayType.click()        Symbol =  
driver.find_element_by_xpath ("//form/div/dl/dd[3]/input")        
Symbol.click()        Symbol.send_keys("TOP")        Quantity = 
driver.find_element_by_name ("quantity")        Quantity.click()        
Quantity.send_keys("1")        Price = driver.find_element_by_name ("price")    
    Price.click()        Price.send_keys("16.99")        Size = 
driver.find_element_by_xpath ("//form/div/dl/dd[6]/select/option[text()='S']")  
      Size.click()        SubmitButton = driver.find_element_by_xpath 
("//form/div/dl/dd[11]/div[2]")        SubmitButton.click()        
ActualOrderMsg = driver.find_element_by_xpath ("//span/p").text         print 
ActualOrderMsg    textPresent = driver.find_element_by_xpath 
("//span/p[contains(text(), 'Successfuly added to processing!')]"               
     #Order1 AddOrder1 = 
driver.find_element_by_xpath("//div/div[2]/form/div[2]/button[1]")  
AddOrder1.click()        member = 
driver.find_element_by_xpath("//form/div/dl/dd[1]/input")        member.click() 
       member.send_keys("USA")        PayType = driver.find_element_by_xpath 
("//form/div/dl/dd[2]/input")        PayType.click()        
PayType.send_keys("USD")        clickPayType = driver.find_element_by_xpath 
("//form/div/dl/dd/ul/li/a")        clickPayType.click()        Symbol =  
driver.find_element_by_xpath ("//form/div/dl/dd[3]/input")        
Symbol.click()        Symbol.send_keys("Sweater")        Quantity = 
driver.find_element_by_name ("quantity")        Quantity.click()        
Quantity.send_keys("2")        Price = driver.find_element_by_name ("price")    
    Price.click()        Price.send_keys("26.99")        Size = 
driver.find_element_by_xpath ("//form/div/dl/dd[6]/select/option[text()='M']")  
      Size.click()        SubmitButton = driver.find_element_by_xpath 
("//form/div/dl/dd[11]/div[2]")        SubmitButton.click()        
ActualOrderMsg = driver.find_element_by_xpath ("//span/p").text         print 
ActualOrderMsg    textPresent = driver.find_element_by_xpath 
("//span/p[contains(text(), 'Successfuly added to processing!')]"               
     #Order2         AddOrder2 = 
driver.find_element_by_xpath("//div/div[2]/form/div[3]/button[1]")  
AddOrder2.click()        member = 
driver.find_element_by_xpath("//form/div/dl/dd[1]/input")        member.click() 
       member.send_keys("USA")        PayType = driver.find_element_by_xpath 
("//form/div/dl/dd[2]/input")        PayType.click()        
PayType.send_keys("USD")        clickPayType = driver.find_element_by_xpath 
("//form/div/dl/dd/ul/li/a")        clickPayType.click()        Symbol =  
driver.find_element_by_xpath ("//form/div/dl/dd[3]/input")        
Symbol.click()        Symbol.send_keys("Sweater")        Quantity = 
driver.find_element_by_name ("quantity")        Quantity.click()        
Quantity.send_keys("1")        Price = driver.find_element_by_name ("price")    
    Price.click()        Price.send_keys("26.99")        Size = 
driver.find_element_by_xpath ("//form/div/dl/dd[6]/select/option[text()='S']")  
      Size.click()        SubmitButton = driver.find_element_by_xpath 
("//form/div/dl/dd[11]/div[2]")        SubmitButton.click()        
ActualOrderMsg = driver.find_element_by_xpath ("//span/p").text         print 
ActualOrderMsg    textPresent = driver.find_element_by_xpath 
("//span/p[contains(text(), 'Successfuly added to processing!')]")

Thanks,SB
                                          
-- 
https://mail.python.org/mailman/listinfo/python-list

Reply via email to