Beispiel #1
0
def mark_status(flag):
    if flag:
        all_logs(Fail)
        testlink(Fail + '\n')
    else:
        all_logs(Pass)
        testlink(Pass + '\n')
Beispiel #2
0
 def log_assert(self, log_text='', expected_text=list(), end=''):
     all_logs('期望结果:操作触发生成的log中包括' + str(expected_text))
     for text in expected_text:
         if text not in log_text:
             self.FailedFlag = True
     all_logs('实际结果:操作触发生成的log:\n' + log_text.replace('', '').replace('', ''))
     testlink('操作触发生成的log:\n' + log_text.replace('', '').replace('', ''))
     testlink(end)
Beispiel #3
0
 def click_action(self, path, location, locator=By.XPATH, response_time=3):
     try:
         self.driver.find_element(locator, path).click()
         time.sleep(response_time)
     except Exception as e:
         print(e)
         self.FailedFlag = True
         all_logs(location + ' is not found')
         testlink(location + ' is not found')
Beispiel #4
0
    def fill_action(self, path, value, location, locator=By.XPATH, response_time=1):

        try:
            self.driver.find_element(locator, path).clear()
            self.driver.find_element(locator, path).send_keys(value)
            time.sleep(response_time)
        except Exception as e:
            print(e)
            self.FailedFlag = True
            all_logs(location + ' is not found')
            testlink(location + ' is not found')
Beispiel #5
0
    def wait_for_element(self, path, location, locator=By.XPATH):
        text = ''
        for i in range(30):
            try:
                if self.driver.find_element(locator, path):
                    text += self.driver.find_element(locator, path).text
                    break
            except Exception as e:
                print(e)
                all_logs(location + ' is not found\n')
                break
            time.sleep(1)
        else:
            all_logs('time out')

        return text
Beispiel #6
0
 def mark_status(self):
     if self.FailedFlag:
         all_logs('-*- The case is executed -*-\n')
         all_logs(self.Fail)
         testlink(self.Fail + '\n')
         self.FailedFlag = False
     else:
         all_logs('-*- The case is executed -*-\n')
         all_logs(self.Pass)
         testlink(self.Pass + '\n')
Beispiel #7
0
 def equal_text_assert(self, path, location, expected_text, end='', locator=By.XPATH):
     try:
         all_logs('期望结果: ' + location + ': ' + expected_text)
         actual_text = self.driver.find_element(locator, path).text
         all_logs('实际结果: ' + location + ': ' + actual_text)
         testlink(location + ': ' + actual_text)
         testlink(end)
         if actual_text != expected_text:
             self.FailedFlag = True
     except Exception as e:
         self.FailedFlag = True
         all_logs('实际结果: ' + str(e))
         testlink(str(e))
         testlink(end)
         all_logs(location + ' is not found\n')
Beispiel #8
0
 def element_attribute(self, path, location, attr_name, expected, end='', locator=By.XPATH):
     try:
         attr = self.driver.find_element(locator, path).get_attribute(attr_name)
         all_logs('期望结果:' + location + '的' + attr_name + '属性值为' + expected)
         all_logs('实际结果:' + location + '的' + attr_name + '属性值为' + attr)
         testlink(location + '的' + attr_name + '属性值为' + attr)
         testlink(end)
         if attr != expected:
             self.FailedFlag = True
     except Exception as e:
         self.FailedFlag = True
         all_logs('实际结果: ' + str(e))
         testlink(str(e))
         testlink(end)
         all_logs(location + ' is not found\n')
Beispiel #9
0
 def no_text_assert(self, path, location, expected_text=list(), end='', locator=By.XPATH):
     try:
         all_logs('期望结果: ' + location + '中不包括' + str(expected_text))
         page_text = self.driver.find_element(locator, path).text
         all_logs('实际结果: ' + location + '中内容为”\n' + page_text + '"')
         testlink(location + '中内容为”\n' + page_text + '"')
         testlink(end)
         for t in expected_text:
             if t in page_text:
                 self.FailedFlag = True
     except Exception as e:
         self.FailedFlag = True
         all_logs('实际结果: ' + str(e))
         testlink(str(e))
         testlink(end)
         all_logs(location + ' is not found\n')
Beispiel #10
0
 def contained_text_assert(self, path, location, expected_text=list(), end='', locator=By.XPATH):
     try:
         all_logs('期望结果: ' + location + '包括: ' + str(expected_text))
         actual_text = self.driver.find_element(locator, path).text
         all_logs('实际结果: ' + location + ': \n' + actual_text)
         testlink(location + ': ' + actual_text)
         testlink(end)
         for t in expected_text:
             if t not in actual_text:
                 self.FailedFlag = True
     except Exception as e:
         self.FailedFlag = True
         all_logs('实际结果: ' + str(e))
         testlink(str(e))
         testlink(end)
         all_logs(location + ' is not found\n')
Beispiel #11
0
 def element_not_exist_assert(self, path, location, end='', locator=By.XPATH):
     try:
         all_logs('期望结果: ' + location + '不存在')
         self.driver.find_element(locator, path)
     except:
         all_logs('实际结果: ' + location + '不存在')
         testlink(location + '不存在')
         testlink(end)
     else:
         self.FailedFlag = True
         all_logs('实际结果: ' + location + ' 存在')
         testlink(location + ' 存在')
         testlink(end)