def setup_class(self):
     self.element = Factory.build("box", name="Test")
     self.flowContainer = self.element.addChildElement(
         Factory.build("flow", name="flow"))
     self.flowContainer.addChildElement(
         Factory.build("Button", name="Button"))
     self.flowContainer.addChildElement(Factory.build("box", name="box"))
Exemplo n.º 2
0
    def setup_method(self, method):
        self.container = Factory.build('Box', '1')
        self.container.key = 'my.test.container'

        self.firstChild = self.container.addChildElement(Factory.build('Textbox',
                                                                       '2'))
        self.firstChild.key = 'my.test.firstChild'
    def test_addProduct(self):
        """test to ensure adding a new webelement to the factory works"""
        class FakeWebElement(WebElement):
            def __init__(self, id=None, name=None, parent=None):
                WebElement.__init__(self, "Id", "Name")

        Factory.addProduct(FakeWebElement)

        createdObject = Factory.build("fakewebelement")
        self.base.addChildElement(createdObject)

        assert createdObject.fullId() == "myPrefix-Id"
        assert createdObject.fullName() == "myPrefix-Name"
        assert createdObject.parent == self.base
Exemplo n.º 4
0
    def test_addProduct(self):
        """test to ensure adding a new webelement to the factory works"""
        class FakeWebElement(WebElement):
            def __init__(self, id=None, name=None, parent=None):
                WebElement.__init__(self, "Id", "Name")

        Factory.addProduct(FakeWebElement)

        createdObject = Factory.build("fakewebelement")
        self.base.addChildElement(createdObject)

        assert createdObject.fullId() == "myPrefix-Id"
        assert createdObject.fullName() == "myPrefix-Name"
        assert createdObject.parent == self.base
    def test_addOptions(self):

        assert self.element.options() == self.options

        newOption = Factory.build("Option", "Option4")
        newOption.setValue("Value4")
        newOption.setText("Text4")
        self.element.addChildElement(newOption)
        self.options['Value4'] = "Text4"
        assert self.element.options() == self.options

        self.element.addOptions({"Value5":"Text5",
                                "Value6":"Text6"})
        self.options["Value5"] = "Text5"
        self.options["Value6"] = "Text6"
        assert self.element.options() == self.options

        self.element.addOption("NewOption")
        assert self.element.options()['NewOption'] == 'NewOption'

        self.element.addOptions(("Value7", "Value8", "Value9"))
        assert self.element.options()['Value7'] == "Value7"
        assert self.element.options()['Value8'] == "Value8"
        assert self.element.options()['Value9'] == "Value9"

        self.element.addOptions((('Value10', 'Key10'), ('Value11', 'Key11'), ('Value12', 'Key12')))
        assert self.element.options()['Key10'] == "Value10"
        assert self.element.options()['Key11'] == "Value11"
        assert self.element.options()['Key12'] == "Value12"
 def test_childAddingBehavior(self):
     link = Factory.build("a")
     if self.element.allowsChildren == True:
         assert self.element.addChildElement(link) != False
         link.remove()
     else:
         assert self.element.addChildElement(link) == False
Exemplo n.º 7
0
    def test_addOptions(self):

        assert self.element.options() == self.options

        newOption = Factory.build("Option", "Option4")
        newOption.setValue("Value4")
        newOption.setText("Text4")
        self.element.addChildElement(newOption)
        self.options['Value4'] = "Text4"
        assert self.element.options() == self.options

        self.element.addOptions({"Value5": "Text5", "Value6": "Text6"})
        self.options["Value5"] = "Text5"
        self.options["Value6"] = "Text6"
        assert self.element.options() == self.options

        self.element.addOption("NewOption")
        assert self.element.options()['NewOption'] == 'NewOption'

        self.element.addOptions(("Value7", "Value8", "Value9"))
        assert self.element.options()['Value7'] == "Value7"
        assert self.element.options()['Value8'] == "Value8"
        assert self.element.options()['Value9'] == "Value9"

        self.element.addOptions(
            (('Value10', 'Key10'), ('Value11', 'Key11'), ('Value12', 'Key12')))
        assert self.element.options()['Key10'] == "Value10"
        assert self.element.options()['Key11'] == "Value11"
        assert self.element.options()['Key12'] == "Value12"
Exemplo n.º 8
0
 def test_childAddingBehavior(self):
     link = Factory.build("a")
     if self.element.allowsChildren == True:
         assert self.element.addChildElement(link) != False
         link.remove()
     else:
         assert self.element.addChildElement(link) == False
Exemplo n.º 9
0
    def test_build(self):
        """test to ensure using the factory to create a webelement object works"""
        createdObject = Factory.build("textbox", "myId", "myName")
        self.base.addChildElement(createdObject)

        assert createdObject.fullId() == "myPrefix-myId"
        assert createdObject.fullName() == "myPrefix-myName"
        assert createdObject.parent == self.base
    def test_tabs(self):
        tab1 = self.element.addChildElement(Factory.build('Tab', 'Tab1'))
        tab2 = self.element.addChildElement(Factory.build('Tab', 'Tab2'))
        tab3 = self.element.addChildElement(Factory.build('Tab', 'Tab3'))
        assert tab1.isSelected
        assert not tab2.isSelected
        assert not tab3.isSelected

        tab2.select()
        assert not tab1.isSelected
        assert tab2.isSelected
        assert not tab3.isSelected

        tab3.select()
        assert not tab1.isSelected
        assert not tab2.isSelected
        assert tab3.isSelected
    def test_tabs(self):
        tab1 = self.element.addChildElement(Factory.build('Tab', 'Tab1'))
        tab2 = self.element.addChildElement(Factory.build('Tab', 'Tab2'))
        tab3 = self.element.addChildElement(Factory.build('Tab', 'Tab3'))
        assert tab1.isSelected
        assert not tab2.isSelected
        assert not tab3.isSelected

        tab2.select()
        assert not tab1.isSelected
        assert tab2.isSelected
        assert not tab3.isSelected

        tab3.select()
        assert not tab1.isSelected
        assert not tab2.isSelected
        assert tab3.isSelected
Exemplo n.º 12
0
 def setup_method(self, element):
     self.element = Factory.build("MultiSelect", "Test")
     self.option1 = Factory.build("Option", "Option1")
     self.option1.setValue("Value1")
     self.option1.setText("Text1")
     self.option2 = Factory.build("Option", "Option2")
     self.option2.setValue("Value2")
     self.option2.setText("Text2")
     self.option3 = Factory.build("Option", "Option3")
     self.option3.setValue("Value3")
     self.option3.setText("Text3")
     self.element.addChildElement(self.option1)
     self.element.addChildElement(self.option2)
     self.element.addChildElement(self.option3)
     self.options = {"Value1":"Text1",
                     "Value2":"Text2",
                     "Value3":"Text3"}
Exemplo n.º 13
0
    def test_build(self):
        """test to ensure using the factory to create a webelement object works"""
        createdObject = Factory.build("textbox", "myId", "myName")
        self.base.addChildElement(createdObject)

        assert createdObject.fullId() == "myPrefix-myId"
        assert createdObject.fullName() == "myPrefix-myName"
        assert createdObject.parent == self.base
Exemplo n.º 14
0
    def test_text(self):
        tab = Factory.build("tab", "Test")
        assert tab.tabLabel.text() == ""
        assert tab.text() == ""
        assert tab.text() == tab.tabLabel.text()

        tab.setProperty('text', 'heyy')
        assert tab.tabLabel.text() == "heyy"
        assert tab.text() == "heyy"
        assert tab.text() == tab.tabLabel.text()
    def test_text(self):
        tab = Factory.build("tab", "Test")
        assert tab.tabLabel.text() == ""
        assert tab.text() == ""
        assert tab.text() == tab.tabLabel.text()

        tab.setProperty('text', 'heyy')
        assert tab.tabLabel.text() == "heyy"
        assert tab.text() == "heyy"
        assert tab.text() == tab.tabLabel.text()
    def test_addRows(self):
        # Using a list of dictionaries to populate a table is the most straight-forward method, but looses column
        # order
        self.element.addRows(({'B':'Row1', 'A':'Row1'}, {'B':'Row2', 'A':'Row2'}))
        assert self.element.columns == ['A', 'B']

        # Using nested tuples when adding rows should allow you to define the order of columns
        newTable = Factory.build('Table', 'Test2')
        newTable.addRows(((('B','Row1'), ('A','Row1')), (('B','Row2'), ('A','Row2'))))
        assert newTable.columns == ['B', 'A']
Exemplo n.º 17
0
 def setup_method(self, element):
     self.element = Factory.build("MultiSelect", "Test")
     self.option1 = Factory.build("Option", "Option1")
     self.option1.setValue("Value1")
     self.option1.setText("Text1")
     self.option2 = Factory.build("Option", "Option2")
     self.option2.setValue("Value2")
     self.option2.setText("Text2")
     self.option3 = Factory.build("Option", "Option3")
     self.option3.setValue("Value3")
     self.option3.setText("Text3")
     self.element.addChildElement(self.option1)
     self.element.addChildElement(self.option2)
     self.element.addChildElement(self.option3)
     self.options = {
         "Value1": "Text1",
         "Value2": "Text2",
         "Value3": "Text3"
     }
    def test_buildFromDictionary(self):
        """test to ensure creating a webelement from a dictionary works"""

        #Try invalid input
        assert type(Factory.buildFromDictionary({})) == Invalid
        assert Factory.buildFromDictionary({'doesNotContainCreate':True}) is False
        assert type(Factory.buildFromDictionary({'create':'SomeElementThatDoesNotExist'})) == Invalid

        paramDict = {'create':'box',
                     'style':'margin:5px;',
                     'childElements':
                        [{'create':'textfield',
                          'id':'My Field A',
                          'style':'margin-bottom:4px; margin-top:7px; clear:both;',
                          'text':'Field 1:',
                          'accessor':'Field1'},
                         {'create':'textfield',
                          'id':'My Field B',
                          'style':'margin-bottom:4px; margin-top:7px; clear:both;',
                          'text':'Field 2:'},
                         {'create':'textareafield',
                          'id':'My Field C',
                          'style':'margin-bottom:4px; margin-top:7px; clear:both;',
                          'text':'Field 3:'}]}

        Factory.addProduct(FakeWebElement)

        accessors = {}
        testObject = Factory.buildFromDictionary(paramDict, {'InputField1':"value"}, accessors=accessors)
        assert testObject.__class__.__name__ == "Box"
        assert testObject.style['margin'] == '5px'

        #Field 1
        childElement = testObject.childElements[0]
        assert childElement.__class__.__name__ == "TextField"
        assert childElement.style == \
                    {'margin-bottom':'4px', 'margin-top':'7px', 'clear':'both'}
        assert childElement.text() == "Field 1:"
        assert childElement.userInput.fullId() == "My Field A"
        assert childElement.userInput.__class__.__name__ == "TextBox"
        assert childElement == accessors['Field1']

        #Field 2
        childElement = testObject.childElements[1]
        assert childElement.__class__.__name__ == "TextField"
        assert childElement.style == {'margin-bottom':'4px', 'margin-top':'7px', 'clear':'both'}
        assert childElement.text() == "Field 2:"
        assert childElement.userInput.fullId() == "My Field B"
        assert childElement.userInput.__class__.__name__ == "TextBox"

        #Field 3
        childElement = testObject.childElements[2]
        assert childElement.__class__.__name__ == "TextAreaField"
        assert childElement.style == \
                    {'margin-bottom':'4px', 'margin-top':'7px', 'clear':'both'}
        assert childElement.text() == "Field 3:"
        assert childElement.userInput.fullId() == "My Field C"
        assert childElement.userInput.__class__.__name__ == "TextArea"
Exemplo n.º 19
0
    def test_valueChanged(self):
        element2 = Factory.build("CheckBox", name="Test2")
        self.element.connect('valueChanged', None, element2, 'setValue')

        self.element.setValue(True)
        assert element2.value() == True
        assert self.element.value() == True
        self.element.setValue(False)
        assert element2.value() == False
        assert self.element.value() == False
        self.element.setValue(True)
        assert element2.value() == True
        assert self.element.value() == True
        element2.setValue(False)
        assert element2.value() == False
        assert self.element.value() == True
Exemplo n.º 20
0
    def test_valueChanged(self):
        element2 = Factory.build("CheckBox", name="Test2")
        self.element.connect('valueChanged', None, element2, 'setValue')

        self.element.setValue(True)
        assert element2.value() == True
        assert self.element.value() == True
        self.element.setValue(False)
        assert element2.value() == False
        assert self.element.value() == False
        self.element.setValue(True)
        assert element2.value() == True
        assert self.element.value() == True
        element2.setValue(False)
        assert element2.value() == False
        assert self.element.value() == True
Exemplo n.º 21
0
    def test_addRows(self):
        # Using a list of dictionaries to populate a table is the most straight-forward method, but looses column
        # order
        self.element.addRows(({
            'B': 'Row1',
            'A': 'Row1'
        }, {
            'B': 'Row2',
            'A': 'Row2'
        }))
        assert self.element.columns == ['A', 'B']

        # Using nested tuples when adding rows should allow you to define the order of columns
        newTable = Factory.build('Table', 'Test2')
        newTable.addRows(
            ((('B', 'Row1'), ('A', 'Row1')), (('B', 'Row2'), ('A', 'Row2'))))
        assert newTable.columns == ['B', 'A']
    def test_buildFromTemplate(self):
        """test to ensure creating a webelement from a dictionary works"""

        #Try invalid input
        assert type(Factory.buildFromTemplate(None)) == Invalid
        assert type(Factory.buildFromTemplate(Template(create=None))) == Invalid
        assert type(Factory.buildFromTemplate(Template('SomeElementThatDoesNotExist'))) == Invalid

        template = Template('box', properties=(('style', 'margin:5px;'),),
                            childElements=(Template('textfield', id='My Field A', accessor="Field1",
                                                properties=(('style', 'margin-bottom:4px; margin-top:7px; clear:both;'),
                                                            ('text', 'Field 1:'))),
                                           Template('textfield', id='My Field B',
                                                properties=(('style', 'margin-bottom:4px; margin-top:7px; clear:both;'),
                                                            ('text', 'Field 2:'))),
                                           Template('textareafield', id='My Field C',
                                                properties=(('style', 'margin-bottom:4px; margin-top:7px; clear:both;'),
                                                            ('text', 'Field 3:'))),
                                                            ))

        Factory.addProduct(FakeWebElement)

        accessors = {}
        testObject = Factory.buildFromTemplate(template, {'InputField1':"value"}, accessors=accessors)
        assert testObject.__class__.__name__ == "Box"
        assert testObject.style['margin'] == '5px'

        #Field 1
        childElement = testObject.childElements[0]
        assert childElement.__class__.__name__ == "TextField"
        assert childElement.style == \
                    {'margin-bottom':'4px', 'margin-top':'7px', 'clear':'both'}
        assert childElement.text() == "Field 1:"
        assert childElement.userInput.fullId() == "My Field A"
        assert childElement.userInput.__class__.__name__ == "TextBox"
        assert childElement == accessors['Field1']

        #Field 2
        childElement = testObject.childElements[1]
        assert childElement.__class__.__name__ == "TextField"
        assert childElement.style == {'margin-bottom':'4px', 'margin-top':'7px', 'clear':'both'}
        assert childElement.text() == "Field 2:"
        assert childElement.userInput.fullId() == "My Field B"
        assert childElement.userInput.__class__.__name__ == "TextBox"

        #Field 3
        childElement = testObject.childElements[2]
        assert childElement.__class__.__name__ == "TextAreaField"
        assert childElement.style == \
                    {'margin-bottom':'4px', 'margin-top':'7px', 'clear':'both'}
        assert childElement.text() == "Field 3:"
        assert childElement.userInput.fullId() == "My Field C"
        assert childElement.userInput.__class__.__name__ == "TextArea"
Exemplo n.º 23
0
    def test_addOptions(self):

        assert self.element.options() == self.options

        newOption = Factory.build("Option", "Option4")
        newOption.setValue("Value4")
        newOption.setText("Text4")
        self.element.addChildElement(newOption)
        self.options['Value4'] = "Text4"
        assert self.element.options() == self.options

        self.element.addOptions({"Value5": "Text5", "Value6": "Text6"})
        self.options["Value5"] = "Text5"
        self.options["Value6"] = "Text6"
        assert self.element.options() == self.options

        self.element.addOption("NewOption")
        assert self.element.options()['NewOption'] == 'NewOption'
def getSingleElementGenerationTimes():
    generationTimes = OrderedDict()
    for product in Factory.products.keys():
        if "." in product:
            continue
        doneSection()
        startTime = time.time()
        scripts = ScriptContainer()
        element = Factory.build(product, 'Test', 'Product')
        element.setScriptContainer(scripts)
        html = element.toHtml()
        html += scripts.toHtml()

        generationTime = time.time() - startTime
        results['createAllOnce'] += generationTime
        generationTimes[generationTime] = (product, len(html))
    results['longestCreationTime'] = generationTimes.orderedKeys[-1]
    return generationTimes
Exemplo n.º 25
0
def getSingleElementGenerationTimes():
    generationTimes = DictUtils.OrderedDict()
    for product in Factory.products.keys():
        if "." in product:
            continue
        doneSection()
        startTime = time.time()
        scripts = ScriptContainer()
        element = Factory.build(product, 'Test', 'Product')
        element.setScriptContainer(scripts)
        html = element.toHTML()
        html += scripts.toHTML()

        generationTime = time.time() - startTime
        results['createAllOnce'] += generationTime
        generationTimes[generationTime] = (product, len(html))
    results['longestCreationTime'] = generationTimes.orderedKeys[-1]
    return generationTimes
Exemplo n.º 26
0
def getGenerationTimeForAllElementsLooped100Times():
    startTime = time.time()
    allProducts = Box('AllProducts')
    scripts = ScriptContainer()
    allProducts.setScriptContainer(scripts)
    for x in xrange(100):
        doneSection()
        for product in Factory.products.keys():
            allProducts.addChildElement(Factory.build(product, 'Test', 'Product'))
    instantiationTime = time.time() - startTime
    results['loopedInit'] = instantiationTime

    startTime = time.time()
    html = allProducts.toHtml()
    html += scripts.toHtml()
    generationTime = (time.time() - startTime)
    results['loopedToHtml'] = generationTime
    results['loopedToHtmlSize'] = len(html)
    results['loopedCreate'] = results['loopedInit'] + results['loopedToHtml']
Exemplo n.º 27
0
    def test_addOptions(self):

        assert self.element.options() == self.options

        newOption = Factory.build("Option", "Option4")
        newOption.setValue("Value4")
        newOption.setText("Text4")
        self.element.addChildElement(newOption)
        self.options['Value4'] = "Text4"
        assert self.element.options() == self.options

        self.element.addOptions({"Value5":"Text5",
                                "Value6":"Text6"})
        self.options["Value5"] = "Text5"
        self.options["Value6"] = "Text6"
        assert self.element.options() == self.options

        self.element.addOption("NewOption")
        assert self.element.options()['NewOption'] == 'NewOption'
Exemplo n.º 28
0
def getGenerationTimeForAllElementsLooped100Times():
    startTime = time.time()
    allProducts = Box('AllProducts')
    scripts = ScriptContainer()
    allProducts.setScriptContainer(scripts)
    for x in xrange(100):
        doneSection()
        for product in Factory.products.keys():
            allProducts.addChildElement(
                Factory.build(product, 'Test', 'Product'))
    instantiationTime = time.time() - startTime
    results['loopedInit'] = instantiationTime

    startTime = time.time()
    html = allProducts.toHtml()
    html += scripts.toHtml()
    generationTime = (time.time() - startTime)
    results['loopedToHtml'] = generationTime
    results['loopedToHtmlSize'] = len(html)
    results['loopedCreate'] = results['loopedInit'] + results['loopedToHtml']
 def setup_class(self):
     self.element = Factory.build("tab", "Test")
 def setup_method(self, element):
     self.element = Factory.build("Image", name="Test")
 def setup_class(self):
     self.element = Factory.build("formError", name="TestFormError")
 def setup_method(self, method):
     self.element = Factory.build("PreformattedText", "Test")
 def setup_class(self):
     self.element = Factory.build('List', 'testList')
 def setup_class(self):
     self.element = Factory.build("Link", "TestLink")
Exemplo n.º 35
0
 def setup_class(self):
     self.element = Factory.build("ResourceFile", "Test")
     self.element.setFile("javascript.js")
Exemplo n.º 36
0
 def setup_class(self):
     self.element = Factory.build("Charts-LineChart")
Exemplo n.º 37
0
 def setup_class(self):
     self.element = Factory.build('JumpToLetter', 'test')
Exemplo n.º 38
0
 def setup_method(self, method):
     self.element = Factory.build("BreadCrumb", "Test")
     self.homeLink = self.element.links[0]
Exemplo n.º 39
0
 def setup_method(self, method):
     self.element = Factory.build('unprintable', 'test')
 def setup_class(self):
     self.element = Factory.build("accordion", "Test")
Exemplo n.º 41
0
 def setup_class(self):
     self.element = Factory.build("Charts-VerticalBarChart")
Exemplo n.º 42
0
 def setup_method(self, method):
     self.element = Factory.build('ItemPager', 'Test')
     self.element.itemsPerPage = 5
     self.element.pagesShownAtOnce = 15
     self.element.connect('jsIndexChanged', None, self, 'fakeJavascript')
 def setup_class(self):
     self.element = Factory.build("autocomplete", "Test")
 def setup_method(self, obj):
     self.element = Factory.build("ToggleButton", "Test")
 def setup_class(self):
     self.element = Factory.build("tab", "Test")
 def setup_method(self, method):
     self.element = Factory.build("Label", "Test")
 def setup_class(self):
     self.element = Factory.build('TabContainer', 'Test')
 def setup_class(self):
     self.element = Factory.build("error", name="Test")
Exemplo n.º 49
0
 def setup_class(self):
     self.element = Factory.build("Charts-PieChart3D")
 def setup_class(self):
     self.element = Factory.build("box")
     self.element.addChildElement(Factory.build("empty", name="Test"))
 def setup_class(self):
     self.element = Factory.build("accordion", "Test")
 def setup_class(self):
     self.element = Factory.build("autocomplete", "Test")
 def setup_class(self):
     self.element = Factory.build("dropdownmenu", "Test")
 def setup_class(self):
     self.element = Factory.build('TabContainer', 'Test')
 def setup_class(self):
     self.element = Factory.build("FormContainer", name="Test")
     self.element.addChildElement(Factory.build("Button", name="Button"))
     self.element.addChildElement(
         Factory.build("Container", name="Container"))
 def setup_class(self):
     self.element = Factory.build("dropdownmenu", "Test")
Exemplo n.º 57
0
 def setup_class(self):
     self.element = Factory.build("Charts-HorizontalBarChart")
 def setup_class(self):
     self.element = Factory.build("FormContainer", name="Test")
     self.element.addChildElement(Factory.build("Button", name="Button"))
     self.element.addChildElement(Factory.build("Container", name="Container"))
Exemplo n.º 59
0
 def setup_class(self):
     self.element = Factory.build("HiddenIntValue", name="Test")