mail@pastecode.io avatar
7 months ago
2.2 kB
To test a double-tap with two fingers simultaneously, your code should perform the following steps:

1. **Initialize two touch actions** for each finger.
2. **Set up each touch action** to perform a tap (or double-tap) at the specified coordinates.
3. **Combine these actions** into a multi-action if necessary.
4. **Perform the actions** simultaneously.

Let's review the relevant portion of your code:

def toggle_subtitles_two_fingers(self):
    # ...
    finger1 = {'x': window_size['width'] * 0.2, 'y': window_size['height'] * 0.5}
    finger2 = {'x': window_size['width'] * 0.3, 'y': window_size['height'] * 0.6}

    action = TouchAction(self.driver)
    action.tap(x=finger1['x'], y=finger1['y'], count=2).wait(10).perform()
    action.tap(x=finger2['x'], y=finger2['y'], count=2).perform()
    # ...

In this section, you are using a single `TouchAction` object (`action`) for both fingers, and the taps are not performed simultaneously. The `perform()` method is called after each tap, which means the taps are sequential, not simultaneous. 

To achieve a simultaneous double-tap with two fingers, you should:

1. Create separate `TouchAction` objects for each finger.
2. Use a `MultiAction` object to combine these touch actions.
3. Perform the combined action only once after setting up both touch actions.

Here's an example of how you could modify your code to achieve a simultaneous double-tap with two fingers:

def toggle_subtitles_two_fingers(self):
    # ...
    finger1 = TouchAction(self.driver)
    finger2 = TouchAction(self.driver)

    # Setup double-tap for each finger
    finger1.tap(x=window_size['width'] * 0.2, y=window_size['height'] * 0.5, count=2)
    finger2.tap(x=window_size['width'] * 0.3, y=window_size['height'] * 0.6, count=2)

    # Combine the actions
    multi_action = MultiAction(self.driver)
    multi_action.add(finger1, finger2)

    # Perform the actions simultaneously
    # ...

This revised approach ensures that both taps are set up first and then executed simultaneously, which is necessary for a double-tap with two fingers.
Leave a Comment