Sending object C from class A to class B

Posted by user278618 on Stack Overflow See other posts from Stack Overflow or by user278618
Published on 2011-03-02T10:15:33Z Indexed on 2011/03/05 15:25 UTC
Read the original article Hit count: 185

Hi,

I can't figure out how to design classes in my system.

In classA I create object selenium (it simulates user actions at website).

In this ClassA I create another objects like SearchScreen, Payment_Screen and Summary_Screen.

# -*- coding: utf-8 -*-
from selenium import selenium
import unittest, time, re

class OurSiteTestCases(unittest.TestCase):
    def setUp(self):
        self.verificationErrors = []

        self.selenium = selenium("localhost", 5555, "*chrome", "http://www.someaddress.com/")
        time.sleep(5)
        self.selenium.start()        

    def test_buy_coffee(self):

        sel = self.selenium

        sel.open('/')
        sel.window_maximize()

        search_screen=SearchScreen(self.selenium)
        search_screen.choose('lavazza')

        payment_screen=PaymentScreen(self.selenium)
        payment_screen.fill_test_data()

        summary_screen=SummaryScreen(selenium)
        summary_screen.accept()


    def tearDown(self):
        self.selenium.stop()
        self.assertEqual([], self.verificationErrors)

if __name__ == "__main__":
    unittest.main()

It's example SearchScreen module:

class SearchScreen:
    def __init__(self,selenium):
        self.selenium=selenium

    def search(self):
        self.selenium.click('css=button.search')

I want to know if there is anything ok with a design of those classes?

© Stack Overflow or respective owner

Related posts about python

Related posts about design-patterns