Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to make appium tests run faster on iOS?

Currently, I am using appium for iOS app testing and I have written tests in Java on mac mini machine. I’m using Jenkins CI to run my tests. I want to run my tests faster as currently its quite slow on iOS simulator. For example, if I enter any value in textfield via sendkeys() function like ’testdata’ then typing speed in emulator is slow. It first write character ’t’ then ‘e’ then ’s’ and so on from simulator’s keyboard.

Following are my questions,

  1. Is there any way I execute my tests faster on simulator specially when entering in textfields through sendkeys() function?
  2. Is there any way I can run my tests without simulator in headless fashion?
like image 664
OsamaA Avatar asked Dec 20 '22 11:12

OsamaA


1 Answers

Don't use send keys on iOS

You're actually not supposed to use sendKeys on iOS because it's slow and flakey.

You're supposed to use setValue for the Java lib and type for the ruby lib

Set Value usage

setValue is defined in Java library here.

It is meant to be called on a WebElement.

driver.find_element(By.locator(value)).setValue("foo")

Using the iOS Simulator is the best option for running tests

A live simulator or real device* is required for Instruments to interact with your application. There are some best practices you can follow to improve your test code which will likely make the tests quicker.

Other best practices for optimization

  1. Do not use "sleeps" to try and wait for an element -- instead constantly poll the driver for if the element is displayed and clickable.
  2. Use setValueinstead of sendKeys
  3. Stop using Xpath locator strategy. It is flakey and slow on iOS. Use UIAutomation or AccessibilityId locator strategy.
  4. Only get the elements when you need to interact with them

*Using Real Devices for iOS is not suggested (when performance matters)

Automating a real device has a builtin delay of one second between every action.

No matter how quick the Appium server is, or your test script is, there is a delay between when Appium pushes the "execute" command to the instruments work queue and when it is executed on the device.

like image 50
Jess Avatar answered Dec 22 '22 02:12

Jess