Beispiel #1
0
 def find_by_swip2(driver: WebDriver, by, locator) -> WebElement:
     driver.implicitly_wait(1)
     elements = driver.find_elements(by, locator)
     while len(elements) == 0:
         driver.swipe(0, 600, 0, 400)
         elements = driver.find_elements(by, locator)
     driver.implicitly_wait(5)
     return elements[0]
def swipe_up_with_distance(driver: WebDriver, distance, peroid):
    """
    向上滑动固定的距离
    :param driver:
    :param peroid:
    :return:
    """
    l = getSize(driver)
    x1 = int(l[0] * 0.5)
    y1 = int(l[1] * 0.9)
    y2 = int(l[1] * 0.9 - distance)
    driver.swipe(x1, y1, x1, y2, peroid)
def swipe_down(driver: WebDriver, peroid):
    """
    向下滑动
    :param driver:
    :param peroid:
    :return:
    """
    l = getSize(driver)
    x1 = int(l[0] * 0.5)
    y1 = int(l[1] * 0.25)
    y2 = int(l[1] * 0.75)
    driver.swipe(x1, y1, x1, y2, peroid)
def swipe_up_small(driver: WebDriver, peroid):
    """
    向上滑动(小距离)
    :param driver:
    :param peroid:
    :return:
    """
    l = getSize(driver)
    x1 = int(l[0] * 0.5)
    y1 = int(l[1] * 0.7)
    y2 = int(l[1] * 0.6)
    driver.swipe(x1, y1, x1, y2, peroid)
Beispiel #5
0
 def swipe_up(self, driver: WebDriver = None, _time: int = 500):
     """
     向上滑动
     :param driver:
     :param _time:
     :return:
     """
     driver = driver or self.driver
     if not driver:
         return driver
     try:
         size = self.get_size(driver)
         x1 = int(size[0] * 0.5)  # 起始x坐标
         y1 = int(size[1] * 0.9)  # 起始y坐标
         y2 = int(size[1] * 0.2)  # 终点y坐标
         driver.swipe(x1, y1, x1, y2, _time)
         return True
     except:
         return False