CtrlK
BlogDocsLog inGet started
Tessl Logo

tessl/maven-org-seleniumhq-selenium--selenium-chromium-driver

Selenium Chrome Driver provides WebDriver implementation for Google Chrome with Chrome DevTools Protocol support, network conditions simulation, permissions management, media casting capabilities, and Chrome-specific service configuration.

Pending
Overview
Eval results
Files

application-launching.mddocs/

Application Launching

Chrome application launching capability allows starting Chrome Apps and managing application lifecycles for testing Chrome OS applications and Chrome extensions.

Application Launch

Launch Chrome App

Start a Chrome application by its ID.

public void launchApp(String id);

Parameters:

  • id (String): Chrome application ID to launch

Usage Example:

ChromiumDriver driver = new ChromiumDriver(commandExecutor, capabilities, "chrome");

// Launch Chrome Calculator app
driver.launchApp("joodangkbfjnajiiifokapkpmhfnpleo");

// Launch Chrome Settings app  
driver.launchApp("chrome://settings/");

// Launch a custom Chrome app
driver.launchApp("your-chrome-app-id");

Common Chrome App IDs

Built-in Chrome Apps

// Common Chrome app IDs
public class ChromeAppIds {
    public static final String CALCULATOR = "joodangkbfjnajiiifokapkpmhfnpleo";
    public static final String CAMERA = "hfhhnacclhffhdffklopdkcgdhifgngh";
    public static final String FILES = "hhaomjibdihmijegdhdafkllkbggdgoj";
    public static final String CHROME_MUSIC_LAB = "dhdgffkkebhmkfjojejmpbldmpobfkfo";
    public static final String SHEETS = "lcabnhkcgbchgbmcjbhkbmlpkjljfcf";
    public static final String DOCS = "aohghmighlieiainnegkcijnfilokake";
    public static final String SLIDES = "felcaaldnbdncclmgdcncolpebgiejap";
}

// Usage
driver.launchApp(ChromeAppIds.CALCULATOR);

Chrome OS System Apps

// Chrome OS specific applications
driver.launchApp("chrome://settings/");        // Settings
driver.launchApp("chrome://history/");         // History
driver.launchApp("chrome://downloads/");       // Downloads
driver.launchApp("chrome://bookmarks/");       // Bookmarks
driver.launchApp("chrome://extensions/");      // Extensions

App Launch Testing

Test App Launch and Interaction

import org.openqa.selenium.support.ui.WebDriverWait;
import org.openqa.selenium.support.ui.ExpectedConditions;
import org.openqa.selenium.WindowType;

public class AppLaunchTest {
    
    public void testCalculatorApp() {
        ChromiumDriver driver = new ChromiumDriver(commandExecutor, capabilities, "chrome");
        
        try {
            // Store original window handle
            String originalWindow = driver.getWindowHandle();
            
            // Launch Calculator app
            driver.launchApp("joodangkbfjnajiiifokapkpmhfnpleo");
            
            // Wait for new window/tab to open
            WebDriverWait wait = new WebDriverWait(driver, Duration.ofSeconds(10));
            wait.until(driver -> driver.getWindowHandles().size() > 1);
            
            // Switch to the app window
            for (String windowHandle : driver.getWindowHandles()) {
                if (!windowHandle.equals(originalWindow)) {
                    driver.switchTo().window(windowHandle);
                    break;
                }
            }
            
            // Interact with calculator
            WebElement numberTwo = wait.until(
                ExpectedConditions.elementToBeClickable(By.xpath("//button[text()='2']"))
            );
            numberTwo.click();
            
            WebElement plusButton = driver.findElement(By.xpath("//button[text()='+']"));
            plusButton.click();
            
            WebElement numberThree = driver.findElement(By.xpath("//button[text()='3']"));
            numberThree.click();
            
            WebElement equalsButton = driver.findElement(By.xpath("//button[text()='=']"));
            equalsButton.click();
            
            // Verify result
            WebElement display = driver.findElement(By.className("display"));
            assertEquals("5", display.getText());
            
        } finally {
            driver.quit();
        }
    }
}

Test Multiple App Launch

public void testMultipleAppLaunch() {
    ChromiumDriver driver = new ChromiumDriver(commandExecutor, capabilities, "chrome");
    
    try {
        // Launch multiple apps
        driver.launchApp("joodangkbfjnajiiifokapkpmhfnpleo"); // Calculator
        Thread.sleep(2000); // Allow time for app to load
        
        driver.launchApp("hfhhnacclhffhdffklopdkcgdhifgngh"); // Camera  
        Thread.sleep(2000);
        
        driver.launchApp("hhaomjibdihmijegdhdafkllkbggdgoj"); // Files
        Thread.sleep(2000);
        
        // Verify multiple windows are open
        Set<String> windowHandles = driver.getWindowHandles();
        assertTrue(windowHandles.size() >= 3);
        
        // Switch between apps and verify they're running
        for (String handle : windowHandles) {
            driver.switchTo().window(handle);
            // Perform app-specific verification
            String title = driver.getTitle();
            assertFalse(title.isEmpty());
        }
        
    } finally {
        driver.quit();
    }
}

Chrome Extension Apps

Launch Installed Extensions

public void launchExtensionApp(ChromiumDriver driver, String extensionId) {
    // Extensions can be launched using their app ID
    driver.launchApp(extensionId);
    
    // Or navigate to extension page
    driver.get("chrome-extension://" + extensionId + "/popup.html");
}

// Example: Launch a custom extension
public void testCustomExtension() {
    ChromiumDriver driver = new ChromiumDriver(commandExecutor, capabilities, "chrome");
    
    // Install extension first (through ChromiumOptions)
    ChromiumOptions<?> options = new ChromiumOptions<>("goog:chromeOptions", "chrome", "chrome");
    options.addExtensions(new File("/path/to/extension.crx"));
    
    // Launch the extension app
    driver.launchApp("your-extension-id-here");
}

App Window Management

Switch Between App Windows

public class AppWindowManager {
    
    public static String findAppWindow(ChromiumDriver driver, String expectedTitle) {
        for (String handle : driver.getWindowHandles()) {
            driver.switchTo().window(handle);
            if (driver.getTitle().contains(expectedTitle)) {
                return handle;
            }
        }
        return null;
    }
    
    public static void closeAppWindow(ChromiumDriver driver, String windowHandle) {
        driver.switchTo().window(windowHandle);
        driver.close();
    }
    
    public static void closeAllAppWindows(ChromiumDriver driver, String mainWindowHandle) {
        Set<String> allWindows = driver.getWindowHandles();
        for (String handle : allWindows) {
            if (!handle.equals(mainWindowHandle)) {
                driver.switchTo().window(handle);
                driver.close();
            }
        }
        driver.switchTo().window(mainWindowHandle);
    }
}

Chrome OS Integration

Test Chrome OS App Integration

public void testChromeOSFileManager() {
    ChromiumDriver driver = new ChromiumDriver(commandExecutor, capabilities, "chrome");
    
    try {
        // Launch Files app
        driver.launchApp("hhaomjibdihmijegdhdafkllkbggdgoj");
        
        // Wait for Files app to load
        WebDriverWait wait = new WebDriverWait(driver, Duration.ofSeconds(10));
        wait.until(ExpectedConditions.titleContains("Files"));
        
        // Interact with file manager
        WebElement downloadsFolder = wait.until(
            ExpectedConditions.elementToBeClickable(By.xpath("//span[text()='Downloads']"))
        );
        downloadsFolder.click();
        
        // Verify navigation
        WebElement breadcrumb = driver.findElement(By.className("breadcrumb"));
        assertTrue(breadcrumb.getText().contains("Downloads"));
        
    } finally {
        driver.quit();
    }
}

Command Integration

The application launching functionality integrates with ChromiumDriverCommandExecutor:

// Command constant from AddHasLaunchApp
public static final String LAUNCH_APP = "launchApp";

App Launch Scenarios

Kiosk Mode Testing

public void testKioskModeApp() {
    ChromiumOptions<?> options = new ChromiumOptions<>("goog:chromeOptions", "chrome", "chrome");
    options.addArguments("--kiosk", "--start-fullscreen");
    
    ChromiumDriver driver = new ChromiumDriver(commandExecutor, capabilities, "chrome");
    
    // Launch app in kiosk mode
    driver.launchApp("your-kiosk-app-id");
    
    // Verify fullscreen mode
    Dimension windowSize = driver.manage().window().getSize();
    Dimension screenSize = Toolkit.getDefaultToolkit().getScreenSize();
    
    assertEquals(screenSize.width, windowSize.width);
    assertEquals(screenSize.height, windowSize.height);
}

App Performance Testing

public void measureAppLaunchTime(String appId) {
    ChromiumDriver driver = new ChromiumDriver(commandExecutor, capabilities, "chrome");
    
    try {
        long startTime = System.currentTimeMillis();
        
        // Launch app
        driver.launchApp(appId);
        
        // Wait for app to be ready
        WebDriverWait wait = new WebDriverWait(driver, Duration.ofSeconds(30));
        wait.until(driver -> driver.getWindowHandles().size() > 1);
        
        // Switch to app window
        String appWindow = null;
        for (String handle : driver.getWindowHandles()) {
            driver.switchTo().window(handle);
            if (!driver.getTitle().isEmpty()) {
                appWindow = handle;
                break;
            }
        }
        
        // Wait for app to be fully loaded
        wait.until(ExpectedConditions.presenceOfElementLocated(By.tagName("body")));
        
        long endTime = System.currentTimeMillis();
        long launchTime = endTime - startTime;
        
        System.out.println("App " + appId + " launched in " + launchTime + "ms");
        
    } finally {
        driver.quit();
    }
}

Error Handling

App launching operations may encounter these exceptions:

  • IllegalArgumentException: When null app ID is provided
  • WebDriverException: When app launch fails or app is not installed
  • TimeoutException: When app takes too long to launch
try {
    driver.launchApp("invalid-app-id");
} catch (IllegalArgumentException e) {
    System.err.println("Invalid app ID: " + e.getMessage());
} catch (WebDriverException e) {
    System.err.println("App launch failed: " + e.getMessage());
}

Best Practices

  1. App Installation: Ensure required apps are installed before launching
  2. Window Management: Properly manage window handles when apps open new windows
  3. Wait Strategies: Use appropriate waits for app loading times
  4. Resource Cleanup: Close app windows to prevent resource leaks
  5. Error Handling: Handle cases where apps are not available or fail to launch
  6. Platform Compatibility: Consider Chrome OS vs regular Chrome differences
  7. Performance Testing: Monitor app launch times for performance regression testing
  8. Extension Testing: Test both built-in apps and custom extensions

Debugging App Launch Issues

Common Issues and Solutions

public class AppLaunchDebugger {
    
    public static void debugAppLaunch(ChromiumDriver driver, String appId) {
        System.out.println("Attempting to launch app: " + appId);
        
        try {
            // Check initial window count
            int initialWindows = driver.getWindowHandles().size();
            System.out.println("Initial window count: " + initialWindows);
            
            // Launch app
            driver.launchApp(appId);
            
            // Wait and check for new windows
            Thread.sleep(3000);
            int finalWindows = driver.getWindowHandles().size();
            System.out.println("Final window count: " + finalWindows);
            
            if (finalWindows > initialWindows) {
                System.out.println("App launched successfully");
                
                // List all window titles
                for (String handle : driver.getWindowHandles()) {
                    driver.switchTo().window(handle);
                    System.out.println("Window: " + driver.getTitle());
                }
            } else {
                System.out.println("App may not have launched - no new windows detected");
            }
            
        } catch (Exception e) {
            System.err.println("App launch error: " + e.getMessage());
        }
    }
}

This application launching system provides comprehensive support for testing Chrome apps, extensions, and Chrome OS applications in automated testing scenarios.

Install with Tessl CLI

npx tessl i tessl/maven-org-seleniumhq-selenium--selenium-chromium-driver

docs

application-launching.md

browser-configuration.md

devtools-protocol.md

index.md

media-casting.md

network-conditions.md

permissions-management.md

service-management.md

webdriver-operations.md

tile.json