Ejemplo n.º 1
0
 def setUp(self):
     self.logger = Logger()
     self.logger.info(
         '######### 发起进攻(  ´-ω ・)▄︻┻┳══━一 ###############################')
     browse = BrowserEngine(self)
     self.driver = browse.open_browser(self)
     BasePage.login(self)
Ejemplo n.º 2
0
 def ji_preview(self, selector):
     el = self.find_element(selector)
     try:
         ActionChains(
             BrowserEngine(self.driver).driver).move_to_element_with_offset(
                 el, 0, 68).click().perform()
         time.sleep(1)
         ActionChains(
             BrowserEngine(self.driver).driver).move_to_element_with_offset(
                 el, -90, 164).context_click().perform()
         Logger().info("The element \' %s \' was moved." % el.text)
     except NameError as e:
         Logger().error("Failed to move to the element with %s" % e)
Ejemplo n.º 3
0
    def acclick(self, selector):

        el = self.find_element(selector)
        try:
            ActionChains(BrowserEngine(self.driver).driver).click(el).perform()
            Logger().info("The element was acclick.")
        except NameError as e:
            Logger().error("Failed to acclick the element with %s" % e)
Ejemplo n.º 4
0
 def chehui(self, selector):
     el = self.find_element(selector)
     try:
         ActionChains(
             BrowserEngine(self.driver).driver).move_to_element_with_offset(
                 el, 242, 83).click().perform()
         Logger().info("The element \' %s \' was moved." % el.text)
     except NameError as e:
         Logger().error("Failed to move to the element with %s" % e)
Ejemplo n.º 5
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!!!!!!!!!!!!!!!!!!!!!!.出现错误提示框'
            )
Ejemplo n.º 6
0
    def click_twice(self, selector):

        el = self.find_element(selector)
        try:
            ActionChains(BrowserEngine(
                self.driver).driver).double_click(el).perform()
            Logger().info("The element \' %s \' was double_clicked." % el.text)
        except NameError as e:
            Logger().error("Failed to click the element with %s" % e)
Ejemplo n.º 7
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))
Ejemplo n.º 8
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
Ejemplo n.º 9
0
 def findtext(self, selector, name):
     try:
         el = self.find_element(selector)
         dr = BrowserEngine(self.driver).driver
         # wait = ui.WebDriverWait(dr, 3)  #等待搜索结果显示3秒
         # wait.until(lambda dr: dr.find_element_by_xpath('//*[@id="ioper_03_1_b"]/div/div[1]/div[2]/label[1]/span[2]').is_displayed())
         text = el.text
         if text == name:
             Logger().info('搜索字段为' + text)
         else:
             raise ValueError('搜索字段不匹配!!!!!!!!!!!!!!!!!!')
     except Exception:
         raise ValueError('无搜索结果')
Ejemplo n.º 10
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!!!!!!!!!!!!!!!!!!')
Ejemplo n.º 11
0
 def jsclick(self, selector):
     el = self.find_element(selector)
     dr = BrowserEngine(self.driver).driver
     dr.execute_script('$(arguments[0]).click()', el)
     Logger().info('js点击方法2')
Ejemplo n.º 12
0
 def setUpClass(cls):
     browser = BrowserEngine(cls)
     cls.driver = browser.open_browser(cls)