Esempio n. 1
0
 def zero_text(self):
     from selenium.common.exceptions import NoSuchElementException
     dr = BrowserEngine(self.driver).driver
     wait = ui.WebDriverWait(dr, 120)
     wait.until(lambda dr: dr.find_element_by_xpath(
         '//*[@id="#modals-container"]/div/div/div[2]/div/div/span').
                is_displayed())
     #error_mes = dr.find_element_by_xpath('/html/body/div[19]/div/h2')
     try:
         error_mes = dr.find_element_by_xpath(
             '//*[@id="#modals-container"]/div/div/div[2]/div/div/p')
         Logger().info('!!!!!!!!!Test pass.计算结果为0!!!!!!!!!')
         link = dr.find_element_by_xpath(
             '//*[@id="#modals-container"]/div/div/div[2]/div/div/span'
         )  #关闭
         link.click()
     except Exception as e:
         BasePage.get_warning_img(self)
         raise ValueError(
             "!!!!!!!!!!!!!!!!!!!!!!Test fail!!!!!!!!!!!!!!!!!!!!!!!!!!!",
             format(e))
Esempio n. 2
0
 def warning_text(self):
     from selenium.common.exceptions import NoSuchElementException
     dr = BrowserEngine(self.driver).driver
     wait = ui.WebDriverWait(dr, 30)
     wait.until(lambda dr: dr.find_element_by_xpath(
         '//*[@id="#modals-container"]/div/div/div[2]/div/h2').is_displayed(
         ))
     #error_mes = dr.find_element_by_xpath('/html/body/div[19]/div/h2')
     try:
         error_mes = dr.find_element_by_xpath(
             '//*[@id="#modals-container"]/div/div/div[2]/div/h2')
         Logger().info('!!!!!!!!!Test pass.提示框出现!!!!!!!!!')
     except Exception as e:
         BasePage.get_warning_img(self)
         raise ValueError(
             "!!!!!!!!!!!!!!!!!!!!!!Test fail!!!!!!!!!!!!!!!!!!!!!!!!!!!.提示框未出现",
             format(e))
     else:
         Logger().info(error_mes.text)
         print('test pass')
         return True
Esempio n. 3
0
 def click_close_result(self):
     #calculate_text = 'x=>/html/body/div[3]/p[1]'
     #result_text = 'x=>/html/body/div[12]/div[2]/div/div[1]/p/span'
     dr = BrowserEngine(self.driver).driver
     wait = ui.WebDriverWait(dr, 120)
     wait.until(lambda dr: dr.find_element_by_xpath(
         '//*[@id="#modals-container"]/div/div/div[2]/div').is_displayed())
     try:
         dr.find_element_by_xpath(
             '//*[@id="#modals-container"]/div/div/div[2]/div/div[1]/span'
         ).is_displayed()  #计算结果框:
         link = dr.find_element_by_xpath(
             '//*[@id="#modals-container"]/div/div/div[2]/div/div[1]/span'
         )  #关闭
         BasePage.get_windows_img(self)
         calculate_text = dr.find_element_by_xpath(
             '//*[@id="#modals-container"]/div/div/div[2]/div/div[2]/table/thead/tr[1]/th'
         )  #计算时间
         result_text = dr.find_element_by_xpath(
             '//*[@id="app"]/div[2]/div[2]/p')  #结果条数
         link.click()
         #dr.execute_script('$(arguments[0]).click()', link)
         Logger().info('%s' % calculate_text.text)
         Logger().info('%s' % result_text.text)
         Logger().info('关闭计算结果')
     except Exception as e:
         if dr.find_element_by_xpath(
                 '//*[@id="#modals-container"]/div/div/div[2]/div/div/span'
         ).is_displayed():
             reason_text = dr.find_element_by_xpath(
                 '//*[@id="#modals-container"]/div/div/div[2]/div/div/p')
             Logger().info('%s' % reason_text.text)
             dr.find_element_by_xpath(
                 '//*[@id="#modals-container"]/div/div/div[2]/div/div/span'
             ).click()
             raise ValueError('计算结果为0!!!!!!!!!!!!!!!!!!')
         else:
             raise ValueError('time out!!!!!!!!!!!!!!!!!!')
Esempio n. 4
0
    def no_warning_text(self):
        from selenium.common.exceptions import NoSuchElementException
        dr = BrowserEngine(self.driver).driver
        #wait = ui.WebDriverWait(dr, 120)
        #wait.until(lambda dr: dr.find_element_by_xpath('/html/body/div[19]/div/h2').is_displayed())
        time.sleep(2)
        try:
            error_mes = dr.find_element_by_xpath(
                '//*[@id="#modals-container"]/div/div/div[2]/div/h2')
        except Exception as e:
            Logger().info("!!!!!!!!!!!Test pass.提示框未出现!!!!!!!!!!!!")

        else:
            BasePage.get_warning_img(self)
            Logger().info(error_mes.text)
            raise ValueError(
                '!!!!!!!!!!!!!!!!!!!!!test false!!!!!!!!!!!!!!!!!!!!!!.出现错误提示框'
            )