Ejemplo n.º 1
0
 def VerifyEnabled(cls, trueOrfalse):
     log.step_normal(u"Element [%s]: Verify Enabled = [%s]" % (cls.__name__, trueOrfalse))
     
     cls.__wait()
     elements = env.threadlocal.BROWSER.find_elements(cls.by, cls.value)
     
     is_disabled = elements[cls.index].get_attribute("disabled")
     log.step_normal(u"Element [%s]: attribute 'is_disabled' = [%s]" % (cls.__name__, is_disabled))
     
     if is_disabled == "true":
         if trueOrfalse == False:
             log.step_pass("Pass...")
         else:
             log.step_fail("Fail...")
     
     elif elements[cls.index].is_enabled():
         if trueOrfalse == True:
             log.step_pass("Pass")
         else:
             log.step_fail("Fail")
     
     else:
         log.step_fail("Not verified.")
     
     
     cls.__clearup()
Ejemplo n.º 2
0
    def VerifyExistence(cls, trueORfalse):
        log.step_normal("Element [%s]: Verify Existence = [%s]." %
                        (cls.__name__, trueORfalse))

        if trueORfalse is True:
            cls.__wait_for_appearing()
        else:
            cls.__wait_for_disappearing()

        elements = env.driver.find_elements(cls.by, cls.value)
        log.step_normal("Element [%s]: Count = [%s]" %
                        (cls.__name__, len(elements)))

        cls.__clearup()

        if len(elements) > 0:
            if trueORfalse is True:
                log.step_pass("Exist!")
            else:
                log.step_fail("Exist!")
        else:
            if trueORfalse is False:
                log.step_pass("Not Exist!")
            else:
                log.step_fail("Not Exist!")
Ejemplo n.º 3
0
    def AlertTextHave(cls, txt_value):
        log.step_normal("AlertTextHave [%s]" % txt_value)
        alert_text = env.BROWSER.switch_to_alert().text()

        if txt_value in alert_text:
            log.step_pass("pass")
        else:
            log.step_fail("fail")
        env.BROWSER.switch_to_default_content()
Ejemplo n.º 4
0
 def AlertTextHave(cls, txt_value):
     log.step_normal("AlertTextHave [%s]" % txt_value)
     alert_text = env.threadlocal.BROWSER.switch_to_alert().text()
     
     if txt_value in alert_text:
         log.step_pass("pass")
     else:
         log.step_fail("fail")
     env.threadlocal.BROWSER.switch_to_default_content()
Ejemplo n.º 5
0
 def VerifyAttribute(cls, name, value, method='equal'):
     '''
     Example:
         NewClaim.Dates.ReminderDate.VerifyAttribute('ng-model', 'hello', method='equal')
         NewClaim.Dates.ReminderDate.VerifyAttribute('ng-model', 'hello', method='contain')
         NewClaim.Dates.ReminderDate.VerifyAttribute('ng-model', 'hello', method='in')
         NewClaim.Dates.ReminderDate.VerifyAttribute('ng-model', 'hello', method='not equal')
     
     Description for "method":
         equal  => real value is 'hello'
         has    => real value contains 'hello', e.g. 'hello world'.
         in     => real value in 'hello', e.g. 'he'
         differ => real value not equal to 'hello', e.g. 'hehe'
     
     '''
     log.step_normal("Element [%s]: VerifyAttribute [%s] <%s> [%s]." % (cls.__name__, name, method, value))
     
     cls.__wait()
     elements = env.threadlocal.BROWSER.find_elements(cls.by, cls.value)
     realvalue = elements[cls.index].get_attribute(name)
     
     if method.lower() == 'equal':
         if value == realvalue:
             log.step_pass("real value=[%s]" % realvalue)
         else:
             log.step_fail("real value=[%s]" % realvalue)
     
     elif method.lower() == 'not equal':
         if not value == realvalue:
             log.step_pass("real value=[%s]" % realvalue)
         else:
             log.step_fail("real value=[%s]" % realvalue)
     
     elif method.lower() == 'contain':
         if value in realvalue:
             log.step_pass("real value=[%s]" % realvalue)
         else:
             log.step_fail("real value=[%s]" % realvalue)
     
     elif method.lower() == 'not contain':
         if not value in realvalue:
             log.step_pass("real value=[%s]" % realvalue)
         else:
             log.step_fail("real value=[%s]" % realvalue)
     
     elif method.lower() == 'in':
         if realvalue in value:
             log.step_pass("real value=[%s]" % realvalue)
         else:
             log.step_fail("real value=[%s]" % realvalue)
     
     else:
         log.step_fail("code error.")
     
     cls.__clearup()
Ejemplo n.º 6
0
 def VerifyInnerHTMLContains(cls, contain_content):
     if contain_content == "": return
     
     log.step_normal("Element [%s]: VerifyInnerHTMLContains [%s]." % (cls.__name__, contain_content))
     
     cls.__wait()
     elements = env.BROWSER.find_elements(cls.by, cls.value)
     inner_html = elements[cls.index].get_attribute('innerHTML')
     
     if contain_content in inner_html:
         log.step_pass("Real inner_hmtl=[%s]" % inner_html)
     else:
         log.step_fail("Real inner_hmtl=[%s]" % inner_html)
     
     cls.__clearup()
Ejemplo n.º 7
0
 def VerifyAttribute(cls, attr, contain_content):
     if contain_content == "": return
     
     log.step_normal("Element [%s]: Verify Attribute [%s] == [%s]." % (cls.__name__, attr, contain_content))
     
     cls.__wait()
     elements = env.BROWSER.find_elements(cls.by, cls.value)
     attr_value = elements[cls.index].get_attribute(attr)
     
     if contain_content == attr_value:
         log.step_pass("Real attr_value=[%s]" % attr_value)
     else:
         log.step_fail("Real attr_value=[%s]" % attr_value)
     
     cls.__clearup()
Ejemplo n.º 8
0
    def VerifyInnerHTMLContains(cls, contain_content):
        if contain_content == "": return

        log.step_normal("Element [%s]: VerifyInnerHTMLContains [%s]." %
                        (cls.__name__, contain_content))

        cls.__wait()
        elements = env.BROWSER.find_elements(cls.by, cls.value)
        inner_html = elements[cls.index].get_attribute('innerHTML')

        if contain_content in inner_html:
            log.step_pass("Real inner_hmtl=[%s]" % inner_html)
        else:
            log.step_fail("Real inner_hmtl=[%s]" % inner_html)

        cls.__clearup()
Ejemplo n.º 9
0
    def VerifyAttribute(cls, attr, contain_content):
        if contain_content == "": return

        log.step_normal("Element [%s]: Verify Attribute [%s] == [%s]." %
                        (cls.__name__, attr, contain_content))

        cls.__wait()
        elements = env.BROWSER.find_elements(cls.by, cls.value)
        attr_value = elements[cls.index].get_attribute(attr)

        if contain_content == attr_value:
            log.step_pass("Real attr_value=[%s]" % attr_value)
        else:
            log.step_fail("Real attr_value=[%s]" % attr_value)

        cls.__clearup()
Ejemplo n.º 10
0
 def VerifyEnabled(cls, trueOrfalse):
     log.step_normal(u"Element [%s]: Verify Enabled = [%s]" % (cls.__name__, trueOrfalse))
     
     cls.__wait()
     elements = env.BROWSER.find_elements(cls.by, cls.value)
     
     if elements[cls.index].is_enabled():
         if trueOrfalse == True:
             log.step_pass("Pass")
         else:
             log.step_fail("Fail")
     else:
         if trueOrfalse == True:
             log.step_fail("Fail")
         else:
             log.step_pass("Pass")
     
     cls.__clearup()
Ejemplo n.º 11
0
 def VerifyAttribute(cls, attr, contain_content):
     if contain_content == "":
         return
     
     log.step_normal("Element [%s]: Verify Attribute [%s] == [%s]." % (cls.__name__, attr, contain_content))
     
     # cls.__wait()
     WebDriverWait(env.driver, 10).until(lambda the_driver:
                                         the_driver.find_element(cls.by, cls.value).is_displayed())
     elements = env.driver.find_elements(cls.by, cls.value)
     attr_value = elements[cls.index].get_attribute(attr)
     
     if contain_content == attr_value:
         log.step_pass("Real attr_value=[%s]" % attr_value)
     else:
         log.step_fail("Real attr_value=[%s]" % attr_value)
     
     cls.__clearup()
Ejemplo n.º 12
0
    def VerifyInnerHTMLNotContains(cls, contain_content):
        if contain_content == "":
            return

        log.step_normal("Element [%s]: VerifyInnerHTMLNotContains [%s]." % (cls.__name__, contain_content))

        # cls.__wait()
        WebDriverWait(env.driver, 10).until(lambda the_driver:
                                            the_driver.find_element(cls.by, cls.value).is_displayed())
        elements = env.driver.find_elements(cls.by, cls.value)
        inner_html = elements[cls.index].get_attribute('innerHTML')

        if contain_content in inner_html:
            log.step_fail("Real inner_hmtl=[%s]" % inner_html)
        else:
            log.step_pass("Real inner_hmtl=[%s]" % inner_html)

        cls.__clearup()
Ejemplo n.º 13
0
    def VerifyEnabled(cls, trueOrfalse):
        log.step_normal(u"Element [%s]: Verify Enabled = [%s]" %
                        (cls.__name__, trueOrfalse))

        cls.__wait()
        elements = env.BROWSER.find_elements(cls.by, cls.value)

        if elements[cls.index].is_enabled():
            if trueOrfalse == True:
                log.step_pass("Pass")
            else:
                log.step_fail("Fail")
        else:
            if trueOrfalse == True:
                log.step_fail("Fail")
            else:
                log.step_pass("Pass")

        cls.__clearup()
Ejemplo n.º 14
0
    def VerifyInnerHTMLNotContains(cls, contain_content):
        if contain_content == "":
            return

        log.step_normal("Element [%s]: VerifyInnerHTMLNotContains [%s]." %
                        (cls.__name__, contain_content))

        # cls.__wait()
        WebDriverWait(env.driver,
                      10).until(lambda the_driver: the_driver.find_element(
                          cls.by, cls.value).is_displayed())
        elements = env.driver.find_elements(cls.by, cls.value)
        inner_html = elements[cls.index].get_attribute('innerHTML')

        if contain_content in inner_html:
            log.step_fail("Real inner_hmtl=[%s]" % inner_html)
        else:
            log.step_pass("Real inner_hmtl=[%s]" % inner_html)

        cls.__clearup()
Ejemplo n.º 15
0
 def VerifyEnabled(cls, trueOrfalse):
     log.step_normal(u"Element [%s]: Verify Enabled = [%s]" % (cls.__name__, trueOrfalse))
     
     # cls.__wait()
     WebDriverWait(env.driver, 10).until(lambda the_driver:
                                         the_driver.find_element(cls.by, cls.value).is_displayed())
     elements = env.driver.find_elements(cls.by, cls.value)
     
     if elements[cls.index].is_enabled():
         if trueOrfalse is True:
             log.step_pass("Pass")
         else:
             log.step_fail("Fail")
     else:
         if trueOrfalse is True:
             log.step_fail("Fail")
         else:
             log.step_pass("Pass")
     
     cls.__clearup()
Ejemplo n.º 16
0
 def VerifyVisible(cls, trueORfalse):
     log.step_normal("Element [%s]: Verify Visible = [%s]." % (cls.__name__, trueORfalse))
     
     cls.__wait()
     
     elements = env.threadlocal.BROWSER.find_elements(cls.by, cls.value)
     log.step_normal("Element [%s]: Count = [%s]" % (cls.__name__, len(elements)))
     
     if elements[cls.index].is_displayed():
         if trueORfalse == True:
             log.step_pass("Visible!")
         else:
             log.step_fail("Visible!")
     else:
         if trueORfalse == False:
             log.step_pass("Not Visible!")
         else:
             log.step_fail("Not Visible!")
     
     cls.__clearup()
Ejemplo n.º 17
0
    def VerifyAttribute(cls, attr, contain_content):
        if contain_content == "":
            return

        log.step_normal("Element [%s]: Verify Attribute [%s] == [%s]." %
                        (cls.__name__, attr, contain_content))

        # cls.__wait()
        WebDriverWait(env.driver,
                      10).until(lambda the_driver: the_driver.find_element(
                          cls.by, cls.value).is_displayed())
        elements = env.driver.find_elements(cls.by, cls.value)
        attr_value = elements[cls.index].get_attribute(attr)

        if contain_content == attr_value:
            log.step_pass("Real attr_value=[%s]" % attr_value)
        else:
            log.step_fail("Real attr_value=[%s]" % attr_value)

        cls.__clearup()
Ejemplo n.º 18
0
 def VerifyInnerHTMLContains(cls, contain_content):
     log.step_normal("Element [%s]: VerifyInnerHTMLContains [%s]." % (cls.__name__, str(contain_content)))
     
     cls.__wait()
     elements = env.threadlocal.BROWSER.find_elements(cls.by, cls.value)
     inner_html = elements[cls.index].get_attribute('innerHTML')
     
     if isinstance(contain_content, list):
         for content in contain_content:
             if content in inner_html:
                 log.step_pass("Real inner_hmtl=[%s]" % inner_html)
             else:
                 log.step_fail("Real inner_hmtl=[%s]" % inner_html)
             
     else:
         if contain_content in inner_html:
             log.step_pass("Real inner_hmtl=[%s]" % inner_html)
         else:
             log.step_fail("Real inner_hmtl=[%s]" % inner_html)
     
     cls.__clearup()
Ejemplo n.º 19
0
    def VerifyEnabled(cls, trueOrfalse):
        log.step_normal(u"Element [%s]: Verify Enabled = [%s]" %
                        (cls.__name__, trueOrfalse))

        # cls.__wait()
        WebDriverWait(env.driver,
                      10).until(lambda the_driver: the_driver.find_element(
                          cls.by, cls.value).is_displayed())
        elements = env.driver.find_elements(cls.by, cls.value)

        if elements[cls.index].is_enabled():
            if trueOrfalse is True:
                log.step_pass("Pass")
            else:
                log.step_fail("Fail")
        else:
            if trueOrfalse is True:
                log.step_fail("Fail")
            else:
                log.step_pass("Pass")

        cls.__clearup()
Ejemplo n.º 20
0
 def VerifyExistence(cls, trueORfalse):
     log.step_normal("Element [%s]: Verify Existence = [%s]." % (cls.__name__, trueORfalse))
     
     if trueORfalse == True:
         cls.__wait_for_appearing()
     else:
         cls.__wait_for_disappearing()
     
     elements = env.threadlocal.BROWSER.find_elements(cls.by, cls.value)
     log.step_normal("Element [%s]: Count = [%s]" % (cls.__name__, len(elements)))
     
     
     cls.__clearup()
     if len(elements) > 0:
         if trueORfalse == True:
             log.step_pass("Exist!")
         else:
             log.step_fail("Exist!")
     else:
         if trueORfalse == False:
             log.step_pass("Not Exist!")
         else:
             log.step_fail("Not Exist!")