Playback on mobile browser

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

Pre-requisites

  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

    danger USE ONLY ONE OF THE METHODS TO SET PROXY, DO NOT USE BOTH.
    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:
    infoThis method will not work if the device is using any VPN service.
    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

Run From Mobile Device

  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. This will open a screen which looks like this:
  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:
      For Android 11 and above version,
      • click on the crt or der links to download Sahi's root certificate.
      • 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,
      • click on the crt or der links to download the Sahi's root certificate.
      • open the downloaded file (if not open automatically) and proceed to the certificate installation process.
    infoNote: In order to open SSL websites in iOS device, turn on SSL trust for Sahi root certificate. Go to SettingsGeneralAboutCertificate 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. Set the File, Start URL and click "Run" to run the script

Run Android Browser Script From Sahi Pro Editor

warning Please ignore the step 1 to step 5 for Android Device which is not tethered with the system or for Android Emulator and ensure that USB debugging is enabled in the android device/emulator and ADB is available on the system. Refer here for more details.
  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. Open Sahi Pro Editor and select a script to execute on the Android browser.
    • Click on Playback.
    • Select Android Browser as Start Mode.
    • Select Android device.
    • Set Start URL.
    • Click on Run.
  7. infoNote: For SSL websites, open Sahi pro launcher page by clicking on Open Sahi Pro Launcher from the application. Then click on the crt or der links to download and install the Sahi root certificate.

Run iOS Browser Script From Sahi Pro Editor

  1. Follow the step 1 to step 5 from Run From Mobile Device.
  2. Open Sahi Pro Editor and select a script to execute on the iOS browser.
    • Click on Playback.
    • Select iOS Browser as Start Mode.
    • Select device which contains Remote as part of device name as iOS device.
    • Set Start URL.
    • Click on Run.