Beispiel #1
0
 def setUp(self):
     log_WARNING("开始执行case")
     chrome_options = Options()
     chrome_options.add_argument('--headless')
     self.driver = webdriver.Chrome(chrome_options=chrome_options)
     #self.driver = webdriver.Chrome()
     self.login_page = Login_page(self.driver)
     self.buy_page = Buy_page(self.driver)
Beispiel #2
0
 def find_element(self, locator):
     """
     :param locator: 传入定位器参数locator=(By.XX,"value")
     :return: 返回元素对象
     """
     # 方法二次封装Demo
     # WebDriverWait(self, driver, timeout, poll_frequency=POLL_FREQUENCY, ignored_exceptions=None)
     # elem = WebDriverWait(driver, timeout, t).until(lambda x: x.findElenmentById("name"))元素显示等待
     # locator定位器,locator(by,value)即是传入元素定位器和元素值)
     if not isinstance(locator, tuple):
         log_ERROR('locator参数类型错误,必须传元祖类型:locator=(By.XX,"value")')
     else:
         log_INFO("正在定位元素信息:定位方式->%s,value值->%s" % (locator[0], locator[1]))
         try:
             time.sleep(2)
             elem = WebDriverWait(self.driver, self.timeout,
                                  self.poll_frequency).until(
                                      lambda x: x.find_element(*locator))
             return elem
         except:
             log_WARNING("定位不到元素")
             return print("定位不到元素")
Beispiel #3
0
 def tearDown(self):
     self.driver.close()
     self.driver.quit()
     log_WARNING("结束执行case")
Beispiel #4
0
 def tearDownClass(cls):
     log_WARNING("类后执行一次")
Beispiel #5
0
 def setUpClass(cls):
     log_WARNING("类前执行一次")
Beispiel #6
0
 def setUp(self):
     log_WARNING("开始执行case")
     self.driver = webdriver.Chrome()
     self.login_page = Login_page(self.driver)
     self.buy_page = Buy_page(self.driver)
     self.register_page = Register_page(self.driver)