Skip to content
Get Free Trial

Run Tests on Mobile Browsers

Since Sahi uses a proxy and injects Javascript, Sahi scripts can run on most mobile browsers.

  1. The Mobile device and System on which Sahi Pro is running should be on the same network.

  2. Find the IP of the laptop (using ipconfig on Windows). We will call it the laptopIP

  3. Configure the proxy settings on the device with proxy host laptopIP and Sahi port 9999

    a) Run below commands in the command prompt (this will set proxy globaly and takes effect right away):

    • To set proxy in Android device/emulator:

      adb shell settings put global http_proxy <host>:<port>

      Eg. adb shell settings put global http_proxy 10.10.2.50:9999

      • To check proxy of Android device/emulator:

        adb shell settings get global http_proxy

        To disable proxy in Android device/emulator:

        adb shell settings put global http_proxy :0

    b) Alternetive way to set proxy in Android device/emulator are below:

    For Android device/emulator having version 8 and above,

    • Turn off the mobile data.
    • Go to Settings > Network & internet > wi-fi > (AndroidWifi) settings > Edit > Advanced options > Proxy > Select the Manual Proxy.
    • Configure Proxy.
    • After setting the proxy, please turn off the wi-fi and turn on again to reflect the proxy.

    For Android emulator only having version 7 and below,

    • Go to Settings > Wireless & networks > Cellular networks > Access Point Names > (create)Sahi_Proxy.
    • Configure APN.
      APN: localhost.sahitest.com
      proxy host: laptopIP from previous step
      proxy port: 9999
  1. Start Sahi on a laptop that is on the same network as the mobile device.

  2. On the mobile browser, navigate to http://laptopIP:9999/. eg. http://10.10.2.50:9999/

  3. The Sahi Pro start page opens, with Run a Script at the top:

    The Sahi Pro start page on a phone: Run a Script, with Script Directory C:/SahiPro/userdata/scripts/, File (Choose a script), Start URL (https://) and a Run button
  4. For automating HTTPS websites in mobile browsers, Sahi’s root certificate must be installed. Below are the steps to install Sahi’s root certificate:

    • In Install SSL Root Certificate on the start page, tap crt or der to download Sahi’s root certificate. The tabs below the buttons repeat the steps for iOS, Android 11+ and Below Android 11:

      Install SSL Root Certificate on the phone start page: the crt, der and pem buttons, the tabs iOS, Android 11+ and Below Android 11, and the iOS steps: tap crt or der to download the certificate; open the Settings app, tap Profile Downloaded and install it; go to Settings › General › About › Certificate Trust Settings and turn on full trust for the Sahi certificate; use Safari on iOS

      For Android 11 and above version

      • Open Settings.
      • Go to Biometrics/Security > Other security settings/Credential Storage (depend on devices) > Install certificates from storage > CA Certificate.
      • Accept the warning alert.
      • Browse to the downloaded certificate and select it.
      • Confirm the certificate installation.

      For below Android 11 version

      • Open the downloaded file (if not open automatically) and proceed to the certificate installation process.

      For iOS device

      • Open the Settings app on your iOS device.

      • You should see a notification that a Profile Downloaded option is available.

      • Tap on the Profile Downloaded and proceed to the certificate installation process.

      • In order to open SSL websites in iOS device, turn on SSL trust for Sahi root certificate. Go to Settings → General → About → Certificate Trust Settings. Under Enable full trust for root certificates, enable trust for the certificate.

  5. Ensure that cookies are allowed in the mobile browser settings.

  6. In Run a Script, choose the File to run, enter the Start URL, and tap Run.

Run Android Browser Script From Sahi Pro Editor

Section titled “Run Android Browser Script From Sahi Pro Editor”
  1. Install Sahi Pro Mobile Web Runner on the device.

  2. Launch the application on the device.

  3. Configure the proxy host and port in the application and Click on Connect.

  4. You will prompt to allow Screen Cast. Click on Start Now.

  5. Once the application is connected to Sahi Pro, connection established message will be shown on the application.

  6. In the Editor, open the test to run in the Android browser, then:

    1. Click Run to open the Run Configuration, and choose Android Browser in Start Mode.
    2. Choose the device in Android Device. Click the refresh icon next to it if the device isn’t listed.
    3. Enter the Start URL.
    4. Click Start Run.
    The Run Configuration with Start Mode Android Browser, Browser chrome, the Android Device and iOS Device boxes with refresh icons, Start URL https://sahitest.com/demo/training/, Scenario File books.s.csv, Filter, Run Type, Export Run Config and Start Run; numbered badges mark Start Mode, Android Device, Start URL and Start Run

Run iOS Browser Script From Sahi Pro Editor

Section titled “Run iOS Browser Script From Sahi Pro Editor”
  1. Follow the step 1 to step 5 from Run From Mobile Device.

  2. In the Editor, open the test to run in the iOS browser, then:

    1. Click Run to open the Run Configuration, and choose iOS Browser in Start Mode.
    2. In iOS Device, choose the device that has Remote in its name.
    3. Enter the Start URL.
    4. Click Start Run.
    The Run Configuration with Start Mode iOS Browser, Browser chrome, the Android Device and iOS Device boxes with refresh icons, Start URL https://sahitest.com/demo/training/, Scenario File books.s.csv, Filter, Run Type, Export Run Config and Start Run; numbered badges mark Start Mode, iOS Device, Start URL and Start Run