Skip to main content

Connecting to QuantumGrid – Hub URL & Session Configuration

To connect your Appium or Selenium tests to QuantumGrid, you first need to obtain the Hub URL from the TestGrid platform.

  1. Log in to your TestGrid account.
  2. Navigate to Real Device Cloud.
  3. Locate the device or browser you want to use.

 

4) Click the Information (ⓘ) icon next to the device.
5) Open the Device Capabilities tab to view the supported capabilities for the selected device.
Copy the Quantum Grid URL from the device information window.


Use the copied URL and required capabilities when creating your Appium or Selenium session.Start every session against the QuantumGrid hub.
Replace {domain} with your environment.

https://{domain}.testgrid.io/quantumgrid/wd/hub

AndroidDriver driver = new AndroidDriver(
new URL("https://{domain}.testgrid.io/quantumgrid/wd/hub"),
capabilities
);

Use the same base URL for all tests. Do not point different tests to individual Appium node URLs unless your team instructs you to do so.

Session Configuration

QuantumGrid uses capabilities to identify the required device and route the session accordingly.

The capability names should match the values configured in your Appium or Selenium test script (for example, W3C alwaysMatch / firstMatch capabilities).

Supported Capabilities

Capability Description Default
appium:platformNameorbrowserName Specifies the target platform. Use appium:platformName with value "android" or "ios" for mobile. Use browserName with value "chrome" for browser. Required
appium:platformVersion Specifies the OS version for automatic device allocation. Optional
appium:udid Routes the session to a specific device. Optional
tg:userToken User authentication token. Required
tg:tags Routes the session to devices matching the specified tag(s). When multiple tags are provided, an OR condition is applied. Optional
tg:queue Controls whether the session enters the queue if no slot is available. Set to false to fail immediately instead of waiting. true
tg:queueTimeout Maximum time (in seconds) the session may wait in the queue before timing out. Minimum: 1 second, Maximum: 1800 seconds (30 minutes). 120
tg:priority Defines the priority of the session in the execution queue. Accepted values are "high" and "low". Sessions with high priority are processed before low priority sessions. For sessions with the same priority, FIFO (First In, First Out) order is followed. If no priority is specified, the session is assigned low priority by default. All users can view queued sessions. low
tg:tunnel Enables TestGrid Tunnel to access applications hosted in a local, private, or internal network environment. Set the value to true to route traffic through the configured tunnel and access locally hosted websites and services during test execution. false
platformTarget Defines whether to run on a real physical device or a virtual device. Accepted values: "Real" or "Virtual" (for Emulators/Simulators). Optional

Session Behavior:

  • Automatic Device Allocation
    • If only appium:platformName and/or appium:platformVersion are configured (without appium:udid), QuantumGrid automatically selects an available device that matches the requested capabilities.
  • Specific Device Allocation
    • If appium:udid is configured, QuantumGrid routes the session to that specific device, subject to availability and queue rulesSample Code
      
      
      import all.main.BaseClass;
      import io.appium.java_client.AppiumDriver;
      import io.appium.java_client.android.AndroidDriver;
      import io.appium.java_client.ios.IOSDriver;
      import org.openqa.selenium.By;
      import org.openqa.selenium.ScreenOrientation;
      import org.openqa.selenium.WebElement;
      import org.openqa.selenium.remote.DesiredCapabilities;
      import org.testng.Assert;
      import org.testng.annotations.Test;
      
      import java.net.URL;
      
      
      public class AutomationTestingiOSTMobileSingleURLSimulator extends BaseClass {
      
      
          AppiumDriver driver;
      
      
          @Test
      
          public void iOSApp1Visual() {
      
              String USER_TOKEN = "User_Token";
              String HUB_URL = "https://{domain}.testgrid.io/quantumgrid/wd/hub";
      
              String platformName = "ios";
              String userToken = USER_TOKEN;
              String projectName = "Test1";
              String deviceID = "";
      
              try {
      
      
                  DesiredCapabilities capabilities = new DesiredCapabilities();
                  capabilities.setCapability("tg:userToken", userToken);
                  capabilities.setCapability("tg:projectName", projectName);
                   capabilities.setCapability("tags", "{TMobile}");
                  //capabilities.setCapability("appium:app","https://{domain}.testgrid.io/app_build/resigned/6a201dac81e42/SampleCounterApp.ipa");
                  capabilities.setCapability("appium:bundleId", "com.apple.mobilesafari");
                  capabilities.setCapability("appium:platformName", platformName);
                  capabilities.setCapability("tg:queueTimeout","1800");
                  capabilities.setCapability("platformTarget", "Virtual");
                  driver = new IOSDriver(new URL(HUB_URL), capabilities);
                  System.out.println("Session started");
      
                  reportTestcaseStarted(driver,"SampleSimulator_TC2");
      
                  int i = 0;
                  while (i < 4) {
                      waitForSeconds(5);
      //                System.out.println("--------------------------------------------------------------------------");
      //                System.out.println(driver.getPageSource());
                      driver.getPageSource();
                      i++;
                  }
      
      
                  reportTestcasePassed(driver,"Passed");
                  quitDriver();
      
      
      
              } catch (Exception e) {
      
                  System.out.println("Something Went Wrong on Device Id " + deviceID);
                  System.out.println(e.getMessage());
                  e.printStackTrace();
                  try {
                      reportTestcaseFailed(driver,"Failed");
                      quitDriver();
                  } catch (Exception e1) {
                      System.out.println(e1.getMessage());
                      e.printStackTrace();
                  }
                  Assert.assertTrue(false,"Test Failed");
              }
      
          }
      
      
      
          public void quitDriver() {
              driver.quit();
      
              System.out.println("Driver Quit called successfully.");
          }
      
      
          public void waitForSeconds(int seconds) {
              try {
                  Thread.sleep(seconds * 1000);
              } catch (InterruptedException e) {
                  System.out.println(e);
                  e.printStackTrace();
                  throw new RuntimeException(e);
              }
          }
      }
Table of Contents