def setUp(self):
self.verificationErrors = []
self.selenium = selenium("loc开发者_JAVA百科alhost", 5555, "*chrome", "http://www.address.com/")
self.selenium.start()
def test_sel__TestCase5(self):
sel = self.selenium
sel.open('/')
and this is a part of code which I'm using in all my testcases:
text='$'
try:
self.failIf(sel.is_text_present(text))
except AssertionError, e:
self.verificationErrors.append(str(e))
so now I have a lot of redundant at this moment.
I'll be grateful if someone help me to create some helper with name SeleniumHelper
with the method Assert. Something like:
class SeleniumHelper:
def __init__(self):
"""Constructor"""
@staticmethod
def AssertText(text):
try: self.failIf(sel.is_text_present(text))
except AssertionError, e: return str(e)
and using it in testcases like
self.verificationErrors.append(SeleniumHelper.AssertText("$"))
You have to pass both self and text if you want to access self.
def assert_text_missing(self, text):
sel = self.selenium
try:
self.failIf(sel.is_text_present(text))
except AssertionError, e:
self.verificationErrors.append(str(e))
And then you'd use it like this:
self.assert_text_missing(text)
精彩评论