FAQs under this topic:
50. How to find locator of Mobile application Element?
51. How to resolve the error message “Simulator architecture is unsupported by the ‘…app’ application. Make sure the correct deployment target has been selected for its compilation in Xcode”?
52. How to switch between Desktop browser and Mobile browser during Mobile test
53. Does Katalon support executing tests with Cloud Mobile Devices?
54. How to use the [Mobile]switchToWebview keyword?
See also Weekly Katalon FAQs
50. How to find locator of Mobile application Element?
In this article, we will guide you on how to identify Locator using Appium Inspector
Step 1: Please make sure Appium is installed by running the command
appium --version
npm install appium-doctor -g
appium-doctor -h
Step 2: Download and install Appium Inspector: Releases · appium/appium-inspector
Start Appium server:
appium --base-path /wd/hub
Step 3: Start Appium Inspector
- Run command before starting:
xattr -cr "/Applications/Appium Inspector.app"
- Run
/Applications/Appium Inspector.app
Step 4: Start the session
{
"appium:deviceName": "emulator-5554",
"platformName": "Android",
"appium:app": "/path/to/apkFiles/ApiDemos-debug.apk"
}
Step 5: Get the locator of elements
Sample custom keyword:
package mypackage
import org.openqa.selenium.remote.DesiredCapabilities
import com.fasterxml.jackson.databind.ObjectMapper
import com.kms.katalon.core.annotation.Keyword
import io.appium.java_client.MobileElement
import io.appium.java_client.android.AndroidDriver
class MobileSupport {
@Keyword
static def getSession(String appiumEnpoint, String desizedCapabilitiesJson) {
Map<String,Object> desizedCapabilities = new ObjectMapper().readValue(desizedCapabilitiesJson, HashMap.class)
DesiredCapabilities caps = new DesiredCapabilities(desizedCapabilities)
AndroidDriver<MobileElement> driver = new AndroidDriver<MobileElement>(new URL(appiumEnpoint), caps)
return driver
}
}
Sample test case:
import [org.openqa.selenium.By](http://org.openqa.selenium.by/)
import org.testng.Assert
import io.appium.java_client.MobileElement
import io.appium.java_client.android.AndroidDriver
import mypackage.MobileSupport
String desCaps = """
{
"appium:deviceName": "emulator-5554",
"platformName": "Android",
"appium:app": "/Users/thanhnhanmai/Documents/apkFiles/ApiDemos-debug.apk"
}
"""
// Open API Demos application
AndroidDriver<MobileElement> driver = MobileSupport.getSession("[http://127.0.0.1:4723/wd/hub"](http://127.0.0.1:4723/wd/hub)", desCaps)
// Verify that the tool bar title is API Demos
By toolBarTitle = By.xpath("/hierarchy/android.widget.FrameLayout/android.view.ViewGroup/android.widget.FrameLayout[1]/android.view.ViewGroup/android.widget.TextView")
Assert.assertEquals(driver.findElement(toolBarTitle).getText(), "API Demos")
// Click App
driver.findElementByAccessibilityId("App").click()
// Click Search
driver.findElementByXPath("//android.widget.TextView[@content-desc='Search']").click()
// Click Invoke Search
driver.findElementByAccessibilityId("Invoke Search").click()
// Fill 'Prefill query'
String seachText = "ABC"
driver.findElement([By.id](http://by.id/)("io.appium.android.apis:id/txt_query_prefill")).sendKeys(seachText)
// Click 'onSearchRequest' button
driver.findElementByAccessibilityId("onSearchRequested()").click()
// Verify content of the address bar
Assert.assertEquals(driver.findElement([By.id](http://by.id/)("android:id/search_src_text")).getText(), seachText)
51. How to resolve the error message “Simulator architecture is unsupported by the ‘…app’ application. Make sure the correct deployment target has been selected for its compilation in Xcode”?
If you are facing the warning:
"Unable to start application
Reason:
Unable to create a new remote session. Please check the server log for more details. Original error: An unknown server-side error occurred while processing the command. Original error: Simulator architecture is unsupported by the application ..."
This exception means your application wasn’t compiled with support for the architecture of your simulator. iOS apps that are compiled to run on a real device won’t work on a desktop/laptop because those chip architectures are different, and vice versa. You will need to ask the developer to compile the application with the build target as a simulator.
Please do try following our official docs to prepare the iOS application file here. Sample iOS project.
Prepare the iOS application file
The Coffee Timer
application located in the App
folder of this sample project is pre-built and signed by the Katalon team to only run on Katalon devices.
As part of the iOS development procedure, to execute the sample test cases with your iOS devices, you need to build and sign the Coffee Timer
application for your iOS devices. Follow these steps:
For XCode simulators
To execute the sample test cases with Xcode simulators, you need to prepare an .app file.
Step 1: Open theCoffee Timer.xcodeproj
project file with Xcode. To find the project save location, go to > App > Your-First-iOS-App > Coffee Timer. Double-click the Coffee Timer.xcodeproj
file.
Step 2: After opening the project in Xcode, choose one of the iOS simulators to launch the apps.
Step 3: To build the .app
file, click Product > Build.
Wait for the build to finish, to find the app file, go to
~/Library/Developer/Xcode/DerivedData/Coffee Timer/Build/Products/Debug-iphonesimulator/Coffee Timer.app.
Note: To quickly search for the DerivedData folder, copy and paste the following path
~/Library/Developer/Xcode/DerivedData
into the Spotlight.
Step 4: Copy and paste the Coffee Time.app
file into the App folder of the sample project. Katalon will use this file to start the Coffee Time
application. Video
For real iOS devices
To execute mobile testing with real iOS devices, you need to prepare an .ipa
file.
Step 1: Open the Coffee Timer.xcodeproj
project file with Xcode. To find the project save location, go to > App > Your-First-iOS-App > Coffee Timer. Double-click the Coffee Timer.xcodeproj
file.
Step 2: After opening the project in Xcode, select a registered iOS device to launch the apps.
Step 3: In the General tab, set the deployment iOS version and select the device type in the Deployment Info section.
Step 4: Switch to the Signing & Capabilities tab, check the Automatically manage signing box, then choose the team that has your device registered in the Apple Developer Portal.
Step 5: To build the .ipa
file, click Product > Build.
Step 6: To archive the .ipa
file, click Product > Archive. If the archive builds successfully, it appears in the Archives organizer.
Step 7: To open the Archives organizer, choose Window > Organizer and click Archives.
Step 8: Select the archive you want to export, then click Distribute App and follow the instructions to get the .ipa
file. Here, we choose a development provisioning profile to export the Coffee Timer.ipa
file.
Step 9: Verify the .ipa
file, do as follows:
- Navigate to Window > Devices and Simulators in Xcode.
- Choose your device from the Devices list.
- Click Add (+) to browse the
.ipa
file. - Once installed successfully, the application appears in the Installed Apps section.
Step 10: Put the Coffee Time.ipa
file into the App folder of the sample project. Katalon will use this file to start the Coffee Time
application.
52. How to switch between Desktop browser and Mobile browser during Mobile test
Scenario:
While running a mobile test, the user would like to open the Desktop browser but when he uses WebUI.openBrowser()
, it starts the mobile browser instead
Expected result:
To navigate to a Desktop browser instead of a Mobile browser during the execution
Solution:
You can set custom Desired Capabilities to run mobile and web at the same time. This is setting custom
See detailed video on how to set the custom Desired Capabilities and scripts.
53. Does Katalon support executing tests with Cloud Mobile Devices?
Execution
Starting with Katalon Studio version 6.3.0, you can test your mobile applications on such custom cloud devices as Sauce Labs, BrowserStack, etc.
Katalon Studio supports running a Mobile script on both remote and custom cloud devices.
Note: Generate Command dialog doesn’t require the Remote Server URL and Remote Server Type, Katalon Studio uses the current settings of Remote execution.
Mobile Object Spy and Mobile Recorder
Starting with Katalon Studio version 6.3.0, Mobile Object Spy and Mobile Recorder are available on remote devices (not custom cloud devices).
Remote Devices
In addition to Android, iOS and Kobiton devices, a new tool item Remote Devices is added to the UI of Mobile Object Spy and Mobile Recorder.
Configure a remote device
You can configure a remote device in 2 ways:
- Project → Settings → Desired Capabilities → Remote → Enter the server URL, server type and desired capabilities.
- Select Mobile Object Spy/Mobile Recorder → Remote Devices. In the configurations field, click Edit. In the pop-up, users can enter the server URL, server type and desired capabilities.
Enter a Cloud Application ID
Cloud Application ID is the ID of the application file (.apk; .ipa) after being uploaded to the cloud. The Kobiton’s application ID, for instance, is kobiton-store:23616.
After you enter the application ID, the Start button is enabled.
54. How to use the [Mobile]switchToWebview keyword?
To switch to a webview on an Android application, the application should enable setWebContentsDebuggingEnabled in their source code before building the apk file. User needs to ask their developer to rebuild their app.
Refer to document of Appium:
- There is an additional step necessary within your app build, unfortunately. As described in the Android remote debugging docs it is necessary to set to true the setWebContentsDebuggingEnabled property on the android.webkit.WebView element.
- How to enable WebViewContentDebugging in source code: How to debug webview remotely?