Ejemplo n.º 1
0
 def find_element(self,by,value): 
     by = self.getby(by)
     try:
         WebDriverWait(self.driver, 10).until(lambda driver:driver.find_element(by,value))
         conf.flag = True
     except Exception,e:
         pass
Ejemplo n.º 2
0
 def is_toast_exist(self, message):
     """查找toast并返回布尔类型结果"""
     toast = '//*[@text="%s"]' % message
     try:
         WebDriverWait(driver, 5, 0.1).until(
             EC.presence_of_element_located((By.XPATH, toast)))
         return True
     except:
         return False
Ejemplo n.º 3
0
 def find_elements(self,by,value):
     #return self.driver.find_element(*loc)
     by = self.getby(by)
     try:
         WebDriverWait(self.driver,10).until(lambda driver:driver.find_elements(by,value))
         conf.flag = True
     except Exception:
         pass
     if conf.flag:
         return self.driver.find_elements(by,value)
Ejemplo n.º 4
0
 def wait_explicit_ele(self, controlInfo, time=20, frequency=1):
     """显式等待元素出现(直到until方法执行完毕,或者等待10秒后等待取消)"""
     WebDriverWait(
         driver, time,
         frequency).until(lambda driver: self.ele.find_element(controlInfo))
Ejemplo n.º 5
0
 def select_editText(self, timeout=10):
     try:
         return WebDriverWait(self.driver, timeout).until(lambda the_driver: the_driver.find_element_by_xpath('//'+self.ui_define['EditText']))
     except Exception, e:
         print(str(e))
Ejemplo n.º 6
0
 def select_textview(self, timeout=10):
     for i in range(timeout):
         try:
             return WebDriverWait(self.driver, timeout).until(lambda the_driver:the_driver.find_element_by_xpath('//XCUIElementTypeTextView'))
         except:
             time.sleep(1)
Ejemplo n.º 7
0
 def find_element_by_accessibility_id(self, acc_id, timeout=15):
     try:
         return MobileElement(WebDriverWait(self.driver, timeout).until(lambda the_driver:the_driver.find_element_by_accessibility_id(acc_id)))
     except:
         return None
Ejemplo n.º 8
0
 def find_element_by_xpath(self, xpath_s, timeout=15):
     try:
         return MobileElement(WebDriverWait(self.driver, timeout).until(lambda the_driver:the_driver.find_element_by_xpath(xpath_s)))
     except:
         return None