Back to Repositories

Testing macOS Progress Bar Crash Prevention in NW.js

This test suite validates the setProgressBar functionality on macOS platforms using Selenium WebDriver, specifically addressing a potential crash issue (#6143) in NW.js. The test ensures stable progress bar updates without application crashes.

Test Coverage Overview

The test provides targeted coverage for macOS-specific progress bar functionality, focusing on crash prevention.

Key areas covered:
  • Platform-specific execution on macOS
  • Progress bar state management
  • Crash prevention verification
  • System stability monitoring

Implementation Analysis

The implementation utilizes Selenium WebDriver with Chrome options to automate the test scenario.

Key patterns include:
  • Platform-specific test filtering
  • WebDriver initialization with custom NW.js app path
  • Implicit wait handling
  • Result verification through DOM element inspection

Technical Details

Testing tools and configuration:
  • Selenium WebDriver for automation
  • Chrome Options for NW.js app configuration
  • Platform detection using Python’s platform module
  • Environment variable integration for ChromeDriver path
  • Timeout management with implicit waits

Best Practices Demonstrated

The test demonstrates robust error handling and platform-specific testing practices.

Notable implementations:
  • Proper test cleanup with driver.quit()
  • Platform-specific test skipping
  • Try-finally block for resource management
  • Clear success criteria definition
  • Explicit wait handling for stability

nwjs/nwJs

test/sanity/issue6143-mac-setProgressBar-crash/test.py

            
import time
import os
import platform
import sys

if platform.system() != 'Darwin':
    print('Skipped for non Mac platform')
    sys.exit(0)

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

driver = webdriver.Chrome(executable_path=os.environ['CHROMEDRIVER'], chrome_options=chrome_options)
driver.implicitly_wait(2)
try:
    print(driver.current_url)
    print('waiting for crash')
    time.sleep(5)
    result = driver.find_element_by_id('result').get_attribute('innerHTML')
    print(result)
    assert('success' in result)
    print('There is no crash')
finally:
    driver.quit()