ldi-github / shirates-core

Integration test framework for mobile apps
https://ldi-github.github.io/shirates-core/
Apache License 2.0
8 stars 0 forks source link

Shirates every action in iOS Automation is 5 seconds each #97

Closed imgeopineda closed 4 months ago

imgeopineda commented 4 months ago

Anyway to make it more faster? Best Configs to use for iOS?

Using Mac mini M2 16 GB

OS: Sonoma 14.5 Appium : 2.5.4

ldi-github commented 4 months ago

We use MacBook Pro with M1 Max and MacStudio with M2 Ultra. It is not unusual for it to take 5 seconds or more in one action.

Shirates is very rich in features, but has limitation of performance in iOS. This limitation is due to the performance of the getPageSource function of the iOS Driver, and is caused by lack of efficient API of iOS to retrieve entire elements.

See https://ldi-github.github.io/shirates-core/in_action/performance_tuning_with_cache_control/performance_problem_of_getpagesource_in_ios.html

If you want your test faster in iOS, consider following items.

  1. Reduce screen elements
  2. Disable auto screenshot
  3. Use Direct Access Mode
  4. Use appium native findElement functions

  1. Reduce screen elements

If you can reduce screen elements by reducing test data, that's the best way to deal this problem. Many cells and elements in the table make your test slower.

shirates-stub is useful to change test data pattern on demand. https://github.com/ldi-github/shirates-stub

  1. Disable auto screenshot

By default, screenshots are taken on change detected. You can disable this feature in testrun.properties (or testrun.global.properties).

For example, you can disable auto screenshot on condition block and action block.

## Screenshot --------------------
onCondition=false
onAction=false
  1. Use Direct Access Mode

Direct Access Mode is faster than Cache Mode (Cache Mode is default). But you can not use powerful functions derived from Cache Mode (e.g. relative selector)

See https://ldi-github.github.io/shirates-core/in_action/performance_tuning_with_cache_control/direct_access_mode.html

  1. Use appium native findElement functions

This is not cross platform approach but fast. Note that you can not get enough reports and screenshots automatically.

Example

Get the latest shirates-core repository. In shirates-core project kotlin/tutorial/inaction/DirectAccessModeIos.kt

    @Test
    @Order(25)
    fun appiumDriverTest() {

        disableCache()

        scenario {
            case(1) {
                condition {
                    appiumDriver.findElement(By.id("General")).click()
                }.action {
                    appiumDriver.findElement(By.id("About")).click()
                }.expectation {
                    appiumDriver.findElement(By.id("Name"))
                        .toTestElement().isFound.thisIsTrue("<Name > exists")
                }
            }
        }

    }
imgeopineda commented 4 months ago

Really appreciate the response. I see it is nice to know that its api limited and not because of my configurations. Thank you so much