Skip to main content

Set geographic location

TestCloud supports setting geographic location for mobile and web testing.

In some test scenarios, you may want to dynamically set geographic location (or geolocation) to:
  • Ensure the website and mobile app display correctly when accessed from different geolocations.

  • Verify that localization features such as language translation, currency change, and time zone changes reflect accurately according to different locations.

  • Confirm that blocked or restricted content like images, content, or videos are blocked as intended from different locations.

There are two ways to set geolocation while executing tests with TestCloud:

  • You can simulate geolocation at the start of testing sessions using the desired capability geoLocation. Open your project in Katalon Studio and go to Project Settings > Desired Capabilities > Remote. Add the String property geoLocation=<country-code>
    geoLocation desired capabilities
  • Add the keyword to your project.
    Note:

    The keyword is also accessible through the Katalon TestCloud Keywords plugin on Katalon Store. You can install the plugin to automatically load all TestCloud keywords into your Katalon project, without having to manually define them. To install the plugin, visit: Katalon TestCloud keywords.

    Use the GeolocationExecutor class with the setMobileGeoLocation method in TestCloud. The keyword class should be created and declared under the com.katalon.testcloud
    package com.katalon.testcloud
    import static com.kms.katalon.core.checkpoint.CheckpointFactory.findCheckpoint
    import static com.kms.katalon.core.testcase.TestCaseFactory.findTestCase
    import static com.kms.katalon.core.testdata.TestDataFactory.findTestData
    import static com.kms.katalon.core.testobject.ObjectRepository.findTestObject
    import static com.kms.katalon.core.testobject.ObjectRepository.findWindowsObject
    import com.kms.katalon.core.annotation.Keyword
    import com.kms.katalon.core.checkpoint.Checkpoint
    import com.kms.katalon.core.cucumber.keyword.CucumberBuiltinKeywords as CucumberKW
    import com.kms.katalon.core.mobile.keyword.MobileBuiltInKeywords as Mobile
    import com.kms.katalon.core.model.FailureHandling
    import com.kms.katalon.core.testcase.TestCase
    import com.kms.katalon.core.testdata.TestData
    import com.kms.katalon.core.testobject.TestObject
    import com.kms.katalon.core.webservice.keyword.WSBuiltInKeywords as WS
    import com.kms.katalon.core.webui.keyword.WebUiBuiltInKeywords as WebUI
    import com.kms.katalon.core.windows.keyword.WindowsBuiltinKeywords as Windows
    import com.kms.katalon.core.configuration.RunConfiguration
    import com.kms.katalon.core.mobile.keyword.internal.MobileDriverFactory;
    import io.appium.java_client.AppiumDriver;
    import com.kms.katalon.core.mobile.keyword.internal.MobileAbstractKeyword;
    import internal.GlobalVariable;
    import org.openqa.selenium.html5.Location

    public class GeolocationExecutor {
    /**
    * Set GPS geolocation for the mobile device.
    *
    * @param latitude the latitude of the location
    * @param longitude the longitude of the location
    * @param altitude the altitude of the location
    */
    @Keyword
    void setMobileGeoLocation(double latitude, double longitude, double altitude) {
    }
    }
Was this page helpful?