or run

npx @tessl/cli init
Log in

Version

Tile

Overview

Evals

Files

Files

docs

application-launching.mdbrowser-configuration.mddevtools-protocol.mdindex.mdmedia-casting.mdnetwork-conditions.mdpermissions-management.mdservice-management.mdwebdriver-operations.md

application-launching.mddocs/

0

# Application Launching

1

2

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

3

4

## Application Launch

5

6

### Launch Chrome App

7

8

Start a Chrome application by its ID.

9

10

```java { .api }

11

public void launchApp(String id);

12

```

13

14

**Parameters:**

15

- `id` (String): Chrome application ID to launch

16

17

**Usage Example:**

18

```java

19

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

20

21

// Launch Chrome Calculator app

22

driver.launchApp("joodangkbfjnajiiifokapkpmhfnpleo");

23

24

// Launch Chrome Settings app

25

driver.launchApp("chrome://settings/");

26

27

// Launch a custom Chrome app

28

driver.launchApp("your-chrome-app-id");

29

```

30

31

## Common Chrome App IDs

32

33

### Built-in Chrome Apps

34

35

```java

36

// Common Chrome app IDs

37

public class ChromeAppIds {

38

public static final String CALCULATOR = "joodangkbfjnajiiifokapkpmhfnpleo";

39

public static final String CAMERA = "hfhhnacclhffhdffklopdkcgdhifgngh";

40

public static final String FILES = "hhaomjibdihmijegdhdafkllkbggdgoj";

41

public static final String CHROME_MUSIC_LAB = "dhdgffkkebhmkfjojejmpbldmpobfkfo";

42

public static final String SHEETS = "lcabnhkcgbchgbmcjbhkbmlpkjljfcf";

43

public static final String DOCS = "aohghmighlieiainnegkcijnfilokake";

44

public static final String SLIDES = "felcaaldnbdncclmgdcncolpebgiejap";

45

}

46

47

// Usage

48

driver.launchApp(ChromeAppIds.CALCULATOR);

49

```

50

51

### Chrome OS System Apps

52

53

```java

54

// Chrome OS specific applications

55

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

56

driver.launchApp("chrome://history/"); // History

57

driver.launchApp("chrome://downloads/"); // Downloads

58

driver.launchApp("chrome://bookmarks/"); // Bookmarks

59

driver.launchApp("chrome://extensions/"); // Extensions

60

```

61

62

## App Launch Testing

63

64

### Test App Launch and Interaction

65

66

```java

67

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

68

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

69

import org.openqa.selenium.WindowType;

70

71

public class AppLaunchTest {

72

73

public void testCalculatorApp() {

74

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

75

76

try {

77

// Store original window handle

78

String originalWindow = driver.getWindowHandle();

79

80

// Launch Calculator app

81

driver.launchApp("joodangkbfjnajiiifokapkpmhfnpleo");

82

83

// Wait for new window/tab to open

84

WebDriverWait wait = new WebDriverWait(driver, Duration.ofSeconds(10));

85

wait.until(driver -> driver.getWindowHandles().size() > 1);

86

87

// Switch to the app window

88

for (String windowHandle : driver.getWindowHandles()) {

89

if (!windowHandle.equals(originalWindow)) {

90

driver.switchTo().window(windowHandle);

91

break;

92

}

93

}

94

95

// Interact with calculator

96

WebElement numberTwo = wait.until(

97

ExpectedConditions.elementToBeClickable(By.xpath("//button[text()='2']"))

98

);

99

numberTwo.click();

100

101

WebElement plusButton = driver.findElement(By.xpath("//button[text()='+']"));

102

plusButton.click();

103

104

WebElement numberThree = driver.findElement(By.xpath("//button[text()='3']"));

105

numberThree.click();

106

107

WebElement equalsButton = driver.findElement(By.xpath("//button[text()='=']"));

108

equalsButton.click();

109

110

// Verify result

111

WebElement display = driver.findElement(By.className("display"));

112

assertEquals("5", display.getText());

113

114

} finally {

115

driver.quit();

116

}

117

}

118

}

119

```

120

121

### Test Multiple App Launch

122

123

```java

124

public void testMultipleAppLaunch() {

125

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

126

127

try {

128

// Launch multiple apps

129

driver.launchApp("joodangkbfjnajiiifokapkpmhfnpleo"); // Calculator

130

Thread.sleep(2000); // Allow time for app to load

131

132

driver.launchApp("hfhhnacclhffhdffklopdkcgdhifgngh"); // Camera

133

Thread.sleep(2000);

134

135

driver.launchApp("hhaomjibdihmijegdhdafkllkbggdgoj"); // Files

136

Thread.sleep(2000);

137

138

// Verify multiple windows are open

139

Set<String> windowHandles = driver.getWindowHandles();

140

assertTrue(windowHandles.size() >= 3);

141

142

// Switch between apps and verify they're running

143

for (String handle : windowHandles) {

144

driver.switchTo().window(handle);

145

// Perform app-specific verification

146

String title = driver.getTitle();

147

assertFalse(title.isEmpty());

148

}

149

150

} finally {

151

driver.quit();

152

}

153

}

154

```

155

156

## Chrome Extension Apps

157

158

### Launch Installed Extensions

159

160

```java

161

public void launchExtensionApp(ChromiumDriver driver, String extensionId) {

162

// Extensions can be launched using their app ID

163

driver.launchApp(extensionId);

164

165

// Or navigate to extension page

166

driver.get("chrome-extension://" + extensionId + "/popup.html");

167

}

168

169

// Example: Launch a custom extension

170

public void testCustomExtension() {

171

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

172

173

// Install extension first (through ChromiumOptions)

174

ChromiumOptions<?> options = new ChromiumOptions<>("goog:chromeOptions", "chrome", "chrome");

175

options.addExtensions(new File("/path/to/extension.crx"));

176

177

// Launch the extension app

178

driver.launchApp("your-extension-id-here");

179

}

180

```

181

182

## App Window Management

183

184

### Switch Between App Windows

185

186

```java

187

public class AppWindowManager {

188

189

public static String findAppWindow(ChromiumDriver driver, String expectedTitle) {

190

for (String handle : driver.getWindowHandles()) {

191

driver.switchTo().window(handle);

192

if (driver.getTitle().contains(expectedTitle)) {

193

return handle;

194

}

195

}

196

return null;

197

}

198

199

public static void closeAppWindow(ChromiumDriver driver, String windowHandle) {

200

driver.switchTo().window(windowHandle);

201

driver.close();

202

}

203

204

public static void closeAllAppWindows(ChromiumDriver driver, String mainWindowHandle) {

205

Set<String> allWindows = driver.getWindowHandles();

206

for (String handle : allWindows) {

207

if (!handle.equals(mainWindowHandle)) {

208

driver.switchTo().window(handle);

209

driver.close();

210

}

211

}

212

driver.switchTo().window(mainWindowHandle);

213

}

214

}

215

```

216

217

## Chrome OS Integration

218

219

### Test Chrome OS App Integration

220

221

```java

222

public void testChromeOSFileManager() {

223

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

224

225

try {

226

// Launch Files app

227

driver.launchApp("hhaomjibdihmijegdhdafkllkbggdgoj");

228

229

// Wait for Files app to load

230

WebDriverWait wait = new WebDriverWait(driver, Duration.ofSeconds(10));

231

wait.until(ExpectedConditions.titleContains("Files"));

232

233

// Interact with file manager

234

WebElement downloadsFolder = wait.until(

235

ExpectedConditions.elementToBeClickable(By.xpath("//span[text()='Downloads']"))

236

);

237

downloadsFolder.click();

238

239

// Verify navigation

240

WebElement breadcrumb = driver.findElement(By.className("breadcrumb"));

241

assertTrue(breadcrumb.getText().contains("Downloads"));

242

243

} finally {

244

driver.quit();

245

}

246

}

247

```

248

249

## Command Integration

250

251

The application launching functionality integrates with ChromiumDriverCommandExecutor:

252

253

```java { .api }

254

// Command constant from AddHasLaunchApp

255

public static final String LAUNCH_APP = "launchApp";

256

```

257

258

## App Launch Scenarios

259

260

### Kiosk Mode Testing

261

262

```java

263

public void testKioskModeApp() {

264

ChromiumOptions<?> options = new ChromiumOptions<>("goog:chromeOptions", "chrome", "chrome");

265

options.addArguments("--kiosk", "--start-fullscreen");

266

267

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

268

269

// Launch app in kiosk mode

270

driver.launchApp("your-kiosk-app-id");

271

272

// Verify fullscreen mode

273

Dimension windowSize = driver.manage().window().getSize();

274

Dimension screenSize = Toolkit.getDefaultToolkit().getScreenSize();

275

276

assertEquals(screenSize.width, windowSize.width);

277

assertEquals(screenSize.height, windowSize.height);

278

}

279

```

280

281

### App Performance Testing

282

283

```java

284

public void measureAppLaunchTime(String appId) {

285

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

286

287

try {

288

long startTime = System.currentTimeMillis();

289

290

// Launch app

291

driver.launchApp(appId);

292

293

// Wait for app to be ready

294

WebDriverWait wait = new WebDriverWait(driver, Duration.ofSeconds(30));

295

wait.until(driver -> driver.getWindowHandles().size() > 1);

296

297

// Switch to app window

298

String appWindow = null;

299

for (String handle : driver.getWindowHandles()) {

300

driver.switchTo().window(handle);

301

if (!driver.getTitle().isEmpty()) {

302

appWindow = handle;

303

break;

304

}

305

}

306

307

// Wait for app to be fully loaded

308

wait.until(ExpectedConditions.presenceOfElementLocated(By.tagName("body")));

309

310

long endTime = System.currentTimeMillis();

311

long launchTime = endTime - startTime;

312

313

System.out.println("App " + appId + " launched in " + launchTime + "ms");

314

315

} finally {

316

driver.quit();

317

}

318

}

319

```

320

321

## Error Handling

322

323

App launching operations may encounter these exceptions:

324

325

- **IllegalArgumentException**: When null app ID is provided

326

- **WebDriverException**: When app launch fails or app is not installed

327

- **TimeoutException**: When app takes too long to launch

328

329

```java

330

try {

331

driver.launchApp("invalid-app-id");

332

} catch (IllegalArgumentException e) {

333

System.err.println("Invalid app ID: " + e.getMessage());

334

} catch (WebDriverException e) {

335

System.err.println("App launch failed: " + e.getMessage());

336

}

337

```

338

339

## Best Practices

340

341

1. **App Installation**: Ensure required apps are installed before launching

342

2. **Window Management**: Properly manage window handles when apps open new windows

343

3. **Wait Strategies**: Use appropriate waits for app loading times

344

4. **Resource Cleanup**: Close app windows to prevent resource leaks

345

5. **Error Handling**: Handle cases where apps are not available or fail to launch

346

6. **Platform Compatibility**: Consider Chrome OS vs regular Chrome differences

347

7. **Performance Testing**: Monitor app launch times for performance regression testing

348

8. **Extension Testing**: Test both built-in apps and custom extensions

349

350

## Debugging App Launch Issues

351

352

### Common Issues and Solutions

353

354

```java

355

public class AppLaunchDebugger {

356

357

public static void debugAppLaunch(ChromiumDriver driver, String appId) {

358

System.out.println("Attempting to launch app: " + appId);

359

360

try {

361

// Check initial window count

362

int initialWindows = driver.getWindowHandles().size();

363

System.out.println("Initial window count: " + initialWindows);

364

365

// Launch app

366

driver.launchApp(appId);

367

368

// Wait and check for new windows

369

Thread.sleep(3000);

370

int finalWindows = driver.getWindowHandles().size();

371

System.out.println("Final window count: " + finalWindows);

372

373

if (finalWindows > initialWindows) {

374

System.out.println("App launched successfully");

375

376

// List all window titles

377

for (String handle : driver.getWindowHandles()) {

378

driver.switchTo().window(handle);

379

System.out.println("Window: " + driver.getTitle());

380

}

381

} else {

382

System.out.println("App may not have launched - no new windows detected");

383

}

384

385

} catch (Exception e) {

386

System.err.println("App launch error: " + e.getMessage());

387

}

388

}

389

}

390

```

391

392

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