Back to Repositories

Testing Process Spawn Stability Integration in NW.js

This test suite validates the spawn crash issue #6056 in NW.js using Selenium WebDriver integration. It focuses on testing process spawning stability and ensures proper handling of child processes to prevent application crashes.

Test Coverage Overview

The test provides comprehensive coverage of process spawning functionality in NW.js applications.

Key areas tested include:
  • Child process creation and management
  • Browser instance spawning via Selenium WebDriver
  • Process cleanup and termination
  • Cross-platform compatibility verification

Implementation Analysis

The implementation utilizes Selenium WebDriver with Python to automate browser instance testing. The approach combines system-level process management with browser automation, leveraging Chrome options for NW.js app testing.

Key patterns include:
  • Custom Chrome driver configuration
  • Automated process lifecycle management
  • Assertion-based result verification

Technical Details

Testing tools and configuration:
  • Selenium WebDriver for browser automation
  • Chrome Options for NW.js app configuration
  • Python subprocess module for process management
  • Custom nw_util helper functions
  • Environment-specific ChromeDriver path configuration

Best Practices Demonstrated

The test implementation showcases robust testing practices for desktop applications.

Notable practices include:
  • Proper resource cleanup in finally blocks
  • Explicit wait management for UI elements
  • Path-independent test execution setup
  • Clear success criteria definition
  • Cross-platform compatibility considerations

nwjs/nwJs

test/sanity/issue6056-spawn-crash/test.py

            
import time
import os
import shutil
import subprocess
import platform
import sys
from subprocess import Popen, PIPE

sys.path.append(os.path.dirname(os.path.dirname(os.path.abspath(__file__))))
from nw_util import *

from selenium import webdriver
from selenium.webdriver.chrome.options import Options
chrome_options = Options()
testdir = os.path.dirname(os.path.abspath(__file__))
chrome_options.add_argument("nwapp=" + testdir)

driver = webdriver.Chrome(executable_path=os.environ['CHROMEDRIVER'], chrome_options=chrome_options)
driver.implicitly_wait(2)
try:
    print(driver.current_url)
    ret = driver.find_element_by_id('result').get_attribute('innerHTML')
    assert('success' in ret)
finally:
    driver.quit()