Tapping app icon to launch
tapAppIcon function
You can tap app icon to launch app with tapAppIcon function.
it.tapAppIcon("Chrome")
This function is optimized for Google Pixel
and iOS
by default.
Configuring parameters
On android devices, hardware manufacturer may install their own graphical user interface(GUI) for home screen and app launcher. You can specify how to tap app icon in profiles with parameter tapAppIconMethod or tapAppIconMacro.
See parameters.
tapAppIconMethod
value | description |
---|---|
auto | Default. In Android, currently same as googlePixel |
googlePixel | Optimized for Google Pixel |
swipeLeftInHome | Find app icon with swiping home screen to left |
tapAppIconMacro
Specify macro name that you created.
Example
profiles
"profiles": [
{
"profileName": "Android/googlePixel",
"tapAppIconMethod": "googlePixel",
"capabilities": {
}
},
{
"profileName": "Android/swipeLeftInHome",
"tapAppIconMethod": "swipeLeftInHome",
"capabilities": {
}
},
{
"profileName": "Android/TapAppIconMacro1",
"tapAppIconMacro": "[TapAppIconMacro1]",
"capabilities": {
}
}
]
TapAppIconMacro.kt
(kotlin/macro/common/TapAppIconMacro.kt
)
package macro.common
import shirates.core.driver.TestDrive
import shirates.core.driver.branchextension.android
import shirates.core.driver.branchextension.ios
import shirates.core.driver.commandextension.*
import shirates.core.driver.wait
import shirates.core.macro.Macro
import shirates.core.macro.MacroObject
@MacroObject
object TapAppIconMacro : TestDrive {
@Macro("[TapAppIconMacro1]")
fun tapAppIconMacro1(appIconName: String) {
android {
it.pressHome()
it.flickBottomToTop()
if (it.canSelectWithScrollDown(appIconName)) {
it.tap()
.wait()
}
}
ios {
it.tapAppIcon(appIconName)
}
}
}
You can use [TapAppIconMacro1]
in your test code.
it.macro("[TapAppIconMacro1]", "Calculator")
Customizing tapAppIcon function
You can customize behavior of tapAppIcon
function by CustomObject. This is better for use.
-
Create a directory named
custom
anywhere undersrc/test/kotlin
. -
Create class named
TapAppIconCustomObject
. - Implement
tapAppIcon
function.
Custom function example
package custom
import shirates.core.customobject.CustomFunction
import shirates.core.customobject.CustomObject
import shirates.core.driver.TestDrive
import shirates.core.driver.branchextension.android
import shirates.core.driver.branchextension.ios
import shirates.core.driver.commandextension.*
@CustomObject
object TapAppIconCustomObject : TestDrive {
@CustomFunction
fun tapAppIcon(appIconName: String) {
android {
it.pressHome()
it.flickBottomToTop()
if (it.canSelectWithScrollDown(appIconName)) {
it.tap()
.wait()
}
}
ios {
it.tapAppIcon(appIconName)
}
}
}
- Build project.
- You can use tapAppIcon in your test code with customized befavior.
it.tapAppIcon("Calculator")