Exemplo n.º 1
0
    def test_long_press_x_y(self):
        el1 = self.driver.find_element_by_name('Content')
        el2 = self.driver.find_element_by_accessibility_id('Animation')

        action = TouchAction(self.driver)
        action.press(el1).move_to(el2).perform()

        el = self.driver.find_element_by_accessibility_id('Views')
        # self.assertIsNotNone(el)
        action.tap(el).perform()

        el = self.driver.find_element_by_accessibility_id('Expandable Lists')
        # self.assertIsNotNone(el)
        action.tap(el).perform()

        el = self.driver.find_element_by_accessibility_id('1. Custom Adapter')
        # self.assertIsNotNone(el)
        action.tap(el).perform()

        # the element "People Names" is located at 0:110 (top left corner)
        action.long_press(x=10, y=120).perform()

        # 'Sample menu' only comes up with a long press, not a tap
        el = self.driver.find_element_by_name('Sample menu')
        self.assertIsNotNone(el)
Exemplo n.º 2
0
    def test_drag_and_drop(self):
        el1 = self.driver.find_element_by_name('Content')
        el2 = self.driver.find_element_by_name('Animation')
        self.driver.scroll(el1, el2)

        el = self.driver.find_element_by_name('Views')
        action = TouchAction(self.driver)
        action.tap(el).perform()

        el = self.driver.find_element_by_name('Drag and Drop')
        action.tap(el).perform()

        dd3 = self.driver.find_element_by_id(
            'com.example.android.apis:id/drag_dot_3')
        dd2 = self.driver.find_element_by_id(
            'com.example.android.apis:id/drag_dot_2')

        # dnd is stimulated by longpress-move_to-release
        action.long_press(dd3).move_to(dd2).release().perform()

        el = self.driver.find_element_by_id(
            'com.example.android.apis:id/drag_result_text')
        self.assertEqual('Dropped!', el.get_attribute('text'))