Exemplo n.º 1
1
def dbl_click_item(id=id, save_screenshot=False, save_screenshot_file=None, max_retry=3):
    _wait_for_id(id=id, save_screenshot=save_screenshot,
                 save_screenshot_file=save_screenshot_file)
    element = driver.find_element_by_id(id)

  

    if platform == 'android':
        actions = TouchActions(driver)
        actions.double_tap(element)

    retry_count = 1
    while retry_count <= max_retry:
        try:
            if platform == 'ios':
                # Fix TBD
                log ('Hacky iOS double tap to a fixed location')
                driver.execute_script('mobile: doubleTap', {'x':200, 'y':200})
            else:
                actions.perform()
        except Exception as e:
            log('action error, try #{}...'.format(retry_count))
            log ('Error reported was: '+str(e))
            retry_count = retry_count + 1
            sleep(2)
        else:
            retry_count = max_retry + 1
            pass
Exemplo n.º 2
0
def dbl_click_item(id=id,
                   save_screenshot=False,
                   save_screenshot_file=None,
                   max_retry=3):
    _wait_for_id(id=id,
                 save_screenshot=save_screenshot,
                 save_screenshot_file=save_screenshot_file)
    element = driver.find_element_by_id(id)

    if platform == 'android':
        actions = TouchActions(driver)
        actions.double_tap(element)

    retry_count = 1
    while retry_count <= max_retry:
        try:
            if platform == 'ios':
                # Fix TBD
                log('Hacky iOS double tap to a fixed location')
                driver.execute_script('mobile: doubleTap', {
                    'x': 200,
                    'y': 200
                })
            else:
                actions.perform()
        except Exception as e:
            log('action error, try #{}...'.format(retry_count))
            log('Error reported was: ' + str(e))
            retry_count = retry_count + 1
            sleep(2)
        else:
            retry_count = max_retry + 1
            pass
    def double_tap(self):
        """。
            Summary:
                双击点赞/取消点赞
        """
        log.logger.info("开始双击")
        # x = self._layout_view.size['width']/2
        # y = self._layout_view.size['height']/2
        # opts = {
        #     'element': self._layout_view.id,
        #     'x': x,
        #     'y': y,
        #     'tapCount': 2.0,
        # }
        # self.base_parent.execute_script('mobile:tap', opts)

        tc = TouchActions(self.base_parent)
        tc.double_tap(self._layout_view)
        tc.perform()

        log.logger.info("双击完毕")
        time.sleep(2)
    def double_click(self, target, analysis=None):
        """ Implements double click as double tap for WinAppDriver
        """

        if analysis:
            analysis('start')

        logger.info('Tapped {0}'.format(target.get_attribute('AutomationId')),
                    also_console=PolarisInterface.output_console)

        touch = TouchActions(self)
        touch.double_tap(target).perform()

        if analysis:
            for i in range(1, 10):
                if not analysis('stop'):
                    touch.perform()
                else:
                    logger.warn(
                        "Trouble interacting with {0}.  Required {1} additional clicks to activate"
                        .format(target.get_attribute('AutomationId'), i))
                    return

            raise AssertionError('Unable to validate click after 10 tries')
Exemplo n.º 5
0
from selenium import webdriver
from selenium.webdriver.common.keys import Keys
from selenium.webdriver.support.expected_conditions import text_to_be_present_in_element
import time
from selenium.webdriver.common.by import By
from selenium.webdriver.common.touch_actions import TouchActions

driver = webdriver.Chrome(executable_path="C:\Driver\chromedriver.exe")
driver.implicitly_wait(5)
driver.maximize_window()
driver.get("https://www.expedia.com")
driver.find_element_by_id("tab-flight-tab-hp").click()
time.sleep(2)
driver.find_element_by_xpath("id=flight-origin-hp-flight").send_keys(NYC)
driver1 = TouchActions()
driver1.double_tap("packageDirectFlight-hp-package")
time.sleep(2)
driver.find_element_by_id("search-button-hp-package").click()
driver.quit()










 def double_tap(self, locator):
     """ Double tap element identified by ``locator``."""
     element = self._element_find(locator, True, True)
     action = TouchActions(self._current_application())
     action.double_tap(element).perform()
'''
Created on May 18, 2018

@author: aranjan
'''
from selenium import webdriver
from selenium.webdriver.common.touch_actions import TouchActions
driver = webdriver.Chrome()
element = driver.find_element_by_class_name("name")
element1 = driver.find_element_by_class_name("namem")
touchaction = TouchActions(driver)
#Double taps on a given element.
touchaction.double_tap(element)
#Flicks, starting anywhere on the screen.
touchaction.flick(100, 100)
#Long press on an element.
touchaction.long_press(element1)
#Touch and scroll, moving by xoffset and yoffset.
touchaction.scroll(100, 200)