appium / appium

Cross-platform automation framework for all kinds of apps, built on top of the W3C WebDriver protocol
http://appium.io/
Apache License 2.0
18.75k stars 6.07k forks source link

Unable to swipe from the bottom to the top to open control center #15950

Closed jstephancc closed 2 years ago

jstephancc commented 2 years ago

The problem

In my tests on iOS devies i need to switch from Wifi to 3G/4G. Up to appium, there is no method to switch it directly by some command. So I'm opening control_center_position from the top or bottom and clicking on the menu controls.

Since appium 1.22 & iOS 15 I'm not able to swipe from the bottom to the top to open control center on iPhone 8. Using any phone i can easily swipe in other way around (top->bottom) and then close (bottom->top).

There is no appium errors./ issues

Environment

Details

My iPhone has screen size: {"width":375,"height":667}

I'm swiping:

        self.driver.swipe(187, 667, 187, 0, 500)

While replacing/switching start_y with end_y, control center will be opened from the top properly.

How can i solve this problem? Or maybe there is another way to check&control network on iOS?

jlipps commented 2 years ago

How is driver.swipe implemented? Is it using W3C actions or some older method? You could try constructing W3C actions yourself.

jstephancc commented 2 years ago

There is simple TouchAction. Tried to implement the same, but no results (no swiping).

    def swipe(self: T, start_x: int, start_y: int, end_x: int, end_y: int, duration: int = 0) -> T:
        """Swipe from one point to another point, for an optional duration.

        Args:
            start_x: x-coordinate at which to start
            start_y: y-coordinate at which to start
            end_x: x-coordinate at which to stop
            end_y: y-coordinate at which to stop
            duration: time to take the swipe, in ms.

        Usage:
            driver.swipe(100, 100, 100, 400)

        Returns:
            Union['WebDriver', 'ActionHelpers']: Self instance
        """
        # `swipe` is something like press-wait-move_to-release, which the server
        # will translate into the correct action
        action = TouchAction(self)
        action.press(x=start_x, y=start_y).wait(ms=duration).move_to(x=end_x, y=end_y).release()
        action.perform()
        return self
jlipps commented 2 years ago

TouchAction is no longer really supported, you'd want to check out the ActionBuilder class and related helpers instead.

mykola-mokhnach commented 2 years ago

There are multiple alternatives to perform a swipe gesture. Check https://www.youtube.com/watch?v=oAJ7jwMNFVU

If none of these work then it is probably a XCTest-specific issue and we cannot do nothing from Appium side.

amedvedjev commented 2 years ago

why not using -> https://support.apple.com/guide/mdm/bundle-ids-for-native-ios-and-ipados-apps-mdm90f60c1ce/web just start Settings using it bundleID?

mykola-mokhnach commented 2 years ago

Closed as third party issue

Sylvie-qa commented 2 years ago

@jstephancc I am having your exact problem trying to swipe up to get control centre. I have basically the same code (using TouchAction) as you showed at the top. My second try was using PointerInput actions, but this also did not work for appium 1.22 and iOS 15.

My code (both methods) works fine with appium 1.22 and iOS 14.8 but NOT with appium 1.22 and iOS 15.

It would be a great help if you could tell me how you solved the problem. This is a real blocker for my automatic tests on iOS 15. Thanks for your help!