Пример #1
0
 def find_element(self, element_info):
     locator_type_name = element_info['locator_type']
     locator_value_info = element_info['locator_value']
     locator_timeout = element_info['timeout']
     if locator_type_name == 'id':
         locator_type = By.ID
     elif locator_type_name == 'name':
         locator_type = By.NAME
     elif locator_type_name == 'class':
         locator_type = By.CLASS_NAME
     elif locator_type_name == 'xpath':
         locator_type = By.XPATH
     element = WebDriverWait(self.driver , locator_timeout)\
         .until(lambda x:x.find_element(locator_type,locator_value_info))
     logger.info('[%s]元素识别成功' % element_info['element_name'])
     # element = WebDriverWait(self.driver, locator_timeout)\
     #     .until(EC.presence_of_element_located((locator_type, locator_value_info)))
     return element
Пример #2
0
 def get_username(self):
     value = self.username_showspan.text
     logger.info('获取用户名成功,用户名是:' + str(value) )
     return value
Пример #3
0
 def input(self, element_info, content):
     element = self.find_element(element_info)
     element.send_keys(content)
     logger.info('[%s]元素输入内容:%s' % (element_info['element_name'], content))
Пример #4
0
 def click(self, element_info):
     element = self.find_element(element_info)
     element.click()
     logger.info('[%s]元素进行点击操作' % element_info['element_name'])
Пример #5
0
 def get_title(self):
     value = self.driver.title
     logger.info('获取网页标题,标题是%s' % value)
     return value
Пример #6
0
 def refresh(self):
     self.driver.refresh()
     logger.info('浏览器刷新操作')
Пример #7
0
 def set_browser_min(self):
     self.driver.minimize_window()
     logger.info('设置浏览器最小化')
Пример #8
0
 def set_browser_max(self):
     self.driver.maximize_window()
     logger.info('设置浏览器最大化')
Пример #9
0
 def open_url(self, url):
     self.driver.get(url)
     logger.info('打开url地址 %s ' % url)