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"
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"