Appium Tips & Tricks
Sauce AI for Test Authoring: Move from intent to execution in minutes.|xBack to ResourcesBlogPosted
Sauce AI for Test Authoring: Move from intent to execution in minutes.
|
x
Blog
Appium Tips & amp; Tricks
As constituent of my work giving conference talks about Appium and provide onsite grooming for organizations, I often encounter originative solutions to common problems people feature with Appium. I thought I & # x27; d share some of those with you in this blog place. One of the most mutual questions I get from teams is about how to have one set of trial for both their iOS and Android applications. It & # x27; s not always possible to share tests between your applications, but if you ’ d like to give it a try here & # x27; s my advice.
As part of my employment yield conference talks about Appium and providing onsite training for organizations, I often encounter creative solutions to common job people have with Appium. I thought I & # x27; d share some of those with you in this blog post.
Writing Cross-Platform Tests
One of the most common questions I get from squad is about how to have one set of tests for both their iOS and Android applications. It & # x27; s not always possible to share tests between your applications, but if you ’ d like to give it a try here & # x27; s my advice.
Sharing the tests between iOS and Android can be a big win in terms of saving time, but in order to do this there is one big requirement. The scenarios you care to automate need to flow exactly the like way in both the iOS and Android versions of your application. What I entail is that it will be easiest to indite if the exploiter journeys are as identical as possible in each of the two apps. If you abstract your tests to the level of user actions, and then make an implementation of those actions for each program, you ’ ll be in good configuration.
Imagine a examination that looks like this:
Log in.
Send a message.
Verify the message exists in the sent messages folder.
A test like this is generic plenty that you should be able to share tryout code between the two platforms.
Now imagine a test like this:
Log in with iCloud.
Create a new document and save it.
Verify the document exists to the iCloud Storage.
This exam can not be shared between iOS and Android as there is no way to copy these steps on an Android test (unless iCloud has added Android support).
It can likewise be difficult to share a test when the stream are different between applications (e.g., the Android application ask the exploiter to sign up before post a message, but after allowing a user to view contacts, while the iOS application asks the user to sign up upon launch the app for the 1st clip). In this case, while sharing a examination might be possible, it will likely result in messy codification and you & # x27; ll probably be best off keep them separate.
All this said, if your applications are identical from a UI point-of-view on iOS and Android, then this is all much simpler for you. All you get to do is make sure the handiness IDs lucifer on the like UI component in each variation of the app, and you can so run the test on both application. All you & # x27; ll have to do is make sure your test sets up the appropriate capabilities for each platform. If you are indite an exclusively webview-based hybrid app, you may simply need to supply the& quot; autoWebView & quot;capability and so the webview automation will kick in on the accurate same page, just hosted on two different platforms.
Automating SMS on iOS
A common challenge Appium users face when automating mobile applications is automating SMS messages (especially on iOS). Many apps send verification code or in early ways require a exploiter to access the message of a text message. Since the Android mechanisation fabric supports changing applications, this problem is simple (though perhaps a bit annoying) to solve. On iOS still, we can not switch applications, so we must be creative.
While I was work with a team in Portugal, they showed me a creative solution to this problem. The gist of it is to set iOS to prove SMS messages as alerts. You can alter this in the settings. Once the preference is set, you can read the message of all SMS content apply the alerts API as they will appear as UIAlerts in your application.
To set the preference:
Open the & quot; Settings & quot; app.
Select & quot; Notifications & quot;.
Select & quot; Messages & quot;
Choose the & quot; Alerts & quot; option
Extra Useful Capabilities
Pro tip: Tools like SUSA can handle this autonomously — upload your app and get results without writing a single test script.
I & # x27; ve likewise assembled a ingathering of some capabilities that you may not know about but can shew extremely utilitarian.
All Platforms
autoWebView- start in the webview context (really useful for Cordova apps)
Android
ignoreUnimportantViews- can speed up your Android tests by trimming out DOM elements that merely exist for organisational function, thus reducing the depth of the DOMnativeWebScreenshot- lead the screenshot from UIAutomator instead of chromedriver. This might be of use to you if you are not seeing what you require in your screenshots.
iOS
locationServicesAuthorized- pre-authorizes locating services (prevents an alert from establish when you try to use the position of a user)Auto [Accept|Dismiss] Alerts- useful to prevent alerts interrupting your testsnativeWebTap- uses non-javascript taps on web messagesafariIgnoreFraudWarning- allows https without proper cert. You may find you require this if your test environments don & # x27; t experience a 100 % perfect SSL apparatusinterKeyDelay- time between keystrokes. This may be useful if Appium & # x27; s speed of typing is do problem with your app (e.g., extreme race conditions no user should ever encounter)sendKeyStrategy- (oneByOne, aggroup, or setValue) Sometimes, you just need to obviate the keyboard altogether.
Network Conditioning
A little known lineament of Appium is the network conditioning API. This is used to assume assorted province of connectivity while running your tests. The complete effectuation is alone presently uncommitted for Android application, but you may chance it quite useful. You can use the* * driver.setNetworkConnection (value) * *to do this.
Here & # x27; s a table of the possible values:
Value (Alias)
Data
WiFi
Airplane Mode
0 (None)
off
off
off
1 (Airplane Mode)
off
off
ON
2 (Wifi only)
off
ON
off
4 (Data only)
ON
off
off
6 (All Network on)
ON
ON
off
That ’ s all for this clip. I hope you found this post helpful. Feel free to pinch me your own Appium tips and trick at @ thedancuellar on Twitter.
Interested in see more about Appium? Download thefrom Dave Haeffner and Matthew Edwards, and besides check out our new Appium education line.
Automate This With SUSA
Upload your APK or URL. SUSA explores like 10 real users — finds bugs, accessibility violations, and security issues. No scripts needed.
Try SUSA FreeTest Your App Autonomously
Upload your APK or URL. SUSA explores like 10 real users — finds bugs, accessibility violations, and security issues. No scripts.
Try SUSA Free