示例#1
0
    def test_contact(self):
        # xpath
        contact_ele = self.driver.find_element(
            MobileBy.XPATH,
            "//*[@text='我' and @resource-id ='com.tencent.mm:id/cns']")
        contact_ele.click()

        contact_ele2 = self.driver.find_element(
            MobileBy.XPATH,
            "//*[@text='收藏' and @resource-id ='android:id/title']")
        contact_ele2.click()
        self.driver.implicitly_wait(20)
        contact_ele2 = self.driver.find_element(
            MobileBy.XPATH,
            "//*[@text='新国都集团开年大吉-2021接力跑挑战赛' and @resource-id ='com.tencent.mm:id/bwa']"
        )
        contact_ele2.click()

        time.sleep(5)
        action0 = TouchAction(self.driver).tap(x=515, y=1419)
        action0.release()
        action0.perform()
        self.driver.implicitly_wait(10)
        var = 1
        while var == 1:
            action1 = TouchAction(self.driver)
            action2 = TouchAction(self.driver)
            mul_action = MultiAction(self.driver)
            action1.tap(x=226, y=1677)
            action2.tap(x=824, y=1707)
            mul_action.add(action1, action2)
            mul_action.perform()
示例#2
0
    def zoom(self, x1, y1, x2, y2, a1, b1, a2, b2):
        size = Common(self.driver).size()
        action1 = TouchAction(self.driver)
        action2 = TouchAction(self.driver)
        zoom_action = MultiAction(self.driver)
        action1.press(x=size[0] * x1, y=size[1] * y1).wait(1000).move_to(x=size[0] * x2, y=size[1] * y2).wait(1000).release()
        action2.press(x=size[0] * a1, y=size[1] * b1).wait(1000).move_to(x=size[0] * a2, y=size[1] * b2).wait(1000).release()

        zoom_action.add(action1, action2)
        zoom_action.perform()
示例#3
0
 def pinch(self):
     x = self.get_Size()[0]
     y = self.get_Size()[1]
     a1 = TouchAction(self.driver).long_press(
         x=x * 0.6, y=y * 0.83).move_to(x=-x * 0.5, y=0).release()
     a2 = TouchAction(self.driver).long_press(
         x=x * 0.4, y=y * 0.83).move_to(x=x * 0.5, y=0).release()
     ma = MultiAction(self.driver)
     ma.add(a1, a2)
     ma.perform()
示例#4
0
 def screen_zoom(self, scale, img_doc):
     """
     屏幕放大、缩小
     :param scale: 为pinch时:缩小,两个手指向内滑动。为zoom时:放大,两个手指向外滑动
     :param img_doc:
     :return:
     """
     # 获取设备大小
     size = self.driver.get_window_size()
     # 定义中心点
     center_point = (size['width'] * 0.5, size['height'] * 0.5)
     # 定义两个外点
     out_point_01 = (size['width'] * 0.2, size['height'] * 0.2)
     out_point_02 = (size['width'] * 0.8, size['height'] * 0.8)
     # 点击一下屏幕
     TouchAction(self.driver).tap(x=size['width'] * 0.5,
                                  y=size['height'] *
                                  0.5).wait(200).perform()
     # pinch:缩小,两个手指向内滑动
     a1 = TouchAction(self.driver).press(x=out_point_01[0], y=out_point_01[1]).wait(200) \
         .move_to(x=center_point[0], y=center_point[1]).wait(200)
     a2 = TouchAction(self.driver).press(x=out_point_02[0], y=out_point_02[1]).wait(200) \
         .move_to(x=center_point[0], y=center_point[1]).wait(200)
     # zoom:放大,两个手指向外滑动
     b1 = TouchAction(self.driver).press(x=center_point[0], y=center_point[1]).wait(200) \
         .move_to(x=out_point_01[0], y=out_point_01[1]).wait(200)
     b2 = TouchAction(self.driver).press(x=center_point[0], y=center_point[1]).wait(200) \
         .move_to(x=out_point_02[0], y=out_point_02[1]).wait(200)
     try:
         logging.info("进行{}操作".format(scale))
         if scale.lower() == 'pinch':
             m = MultiAction(self.driver)
             m.add(a1, a2)
             m.perform()
         elif scale.lower() == 'zoom':
             m = MultiAction(self.driver)
             m.add(b1, b2)
             m.perform()
     except Exception as e:
         logging.error("进行{}操作失败!".format(scale))
         self.save_page_screenshot(img_doc)
         raise e
示例#5
0
def toSmaller():
    action1 = TouchAction(driver)
    action2 = TouchAction(driver)
    big_action = MultiAction(driver)

    action1.press(x=x * 0.2, y=y * 0.2).wait(1000).move_to(
        x=x * 0.4, y=y * 0.4).wait(1000).release()
    action2.press(x=x * 0.8, y=y * 0.8).wait(1000).move_to(
        x=x * 0.6, y=y * 0.6).wait(1000).release()
    print("开始缩小")
    big_action.add(action1, action2)
    big_action.perform()