Here is collected the list of tips and tricks how to solve some issue during automation of mobile iOS app with Appium.

1. Hide keyboard. It’s a simple method that easy work for Android but not so easy for iOS. So, the ways how to hide keyboard for iOS devices:

– self.driver.hide_keyboard(‘return’) – for iPhone will simulate the clicking on Return button. But sometimes this method is not hiding the keyboard but just switching to another text fields.

– Also for iPhone possible to simulate quick swipe from the middle of the screen to the bottom. I will close keyboard. This method work for 95% of cases.

– For iPad need to tap by coordinates on the bottom right side of the screen (minus 30 pixels for height and width).

2. How to send some keys without using of the known methods like set_value or send_keys using UI Automation calls? You need to click on the TextField to open a keyboard and then execute:

– self.driver.execute_script(

‘var vKeyboard = target.frontMostApp().keyboard(); vKeyboard.setInterKeyDelay(0.1);vKeyboard.typeString(“some string”);’


3. How to set the date in the PickerWheel. You don’t need to swipe nothing. Just take the location of the correct PickerWheel and perform the method send_keys(‘value’) to this Picker element. After setting the date to this element – question: how to close it? Just click somewhere on the screen (not on the Picker).

4. Everybody knows that method send_keys() works very slow. So, You need to use method set_value(). It will set the value of Text Field immediately. Or, You can use trick from the list-item #2, just set keyDelay very short.

5. How to verify 10 elements on the page (let’s say just simple static text or labels)? Usually  – we call find_element_by_..() for each of elements. But it will perform the call to Appium server, getting XML for each element. It’s very long. So, You need to grab the page source using self.driver.page_source and look for each element in the already received XML document.

6. How not to fight with popup on iOS app. Usually popups are very painful question. Especially – how to close them if it’s unpredictable. If You don’t need to to verify the text on popup or something like this – You need to add the next capabilities:

‘autoAcceptAlerts’: True, ‘acceptAllAlerts’: True

7. But how to deal with popup if You don’t want to close everything automatically? You need to wrap such 2 methods:


The accepting of alerts is very unstable, so be ready to wrap it into try-except block.

8. How to handle some of alerts using direct call to UI Automation:

self.driver.execute_script(‘var target = UIATarget.localTarget();’)

9. How to minimise the time of searching elements for Your framework? For Android everything is obviously – need to use ID. But what to do with iOS. The better way to decrease the time of element’s searching is the using of accurate xpaths. It’s not very clear from the perspective of  clean code, but it’s faster. So, if You don’t care about quality but about speed use the full xpaths (e.g. //UIAApplication[1]/UIAWindow[1]/…)

10. How to use the last version of Appium every time? You need to pull the Appium code from GitHub, run the file to build it and enable in the Developer Settings of Appium. Now You have the latest version of Appium.